Juliatzin
Juliatzin

Reputation: 19695

Add a new route with SailsJS

I'm newbie with SailJS.

I want to create a new route, so I added this line in config/routes.js:

  'GET /operation/:operationId/sums': 'OperationController.getSums',

Then my function:

getSums: async function (req, res) {
    return res.status(200).json("OK");
  }

But I just get:

Forbidden

with a 403 status code. Other routes works well.

What can I do to fix it ?

Upvotes: 1

Views: 33

Answers (1)

arbuthnott
arbuthnott

Reputation: 3819

Probably some middleware is rejecting this request. Try looking in your config/policies.js file.

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).

Look for '*': false or 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.

Upvotes: 1

Related Questions