[英]Add a new route with SailsJS
I'm newbie with SailJS.我是 SailJS 的新手。
I want to create a new route, so I added this line in config/routes.js
:我想创建一个新路由,所以我在config/routes.js
中添加了这一行:
'GET /operation/:operationId/sums': 'OperationController.getSums',
Then my function:然后我的 function:
getSums: async function (req, res) {
return res.status(200).json("OK");
}
But I just get:但我只是得到:
Forbidden
with a 403
status code.带有403
状态码。 Other routes works well.其他路线运作良好。
What can I do to fix it?我能做些什么来修复它?
Probably some middleware is rejecting this request.可能某些中间件正在拒绝此请求。 Try looking in your config/policies.js
file.尝试查看您的config/policies.js
文件。
It's possible there to set default permissions for all routes, or all routes for a given controller to false
, ie, permit nobody (and in that case then you'd usually go in and override the defaults for particular routes).可以将所有路由或给定 controller 的所有路由的默认权限设置为false
,即不允许任何人(在这种情况下,您通常会在 go 中设置并覆盖特定路由的默认值)。
Look for '*': false
or OperationController: { '*': false }
.寻找'*': false
或OperationController: { '*': false }
。 If you don't see those, then try to see what routes are attached to your new route.如果您没有看到这些,请尝试查看哪些路线附加到您的新路线。 Possibly, a custom created policy is rejecting the request.可能,自定义创建的策略正在拒绝该请求。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.