Reputation: 23
I have SPA sails app. All route i my SPA app, at first enter in welcome action controller.
'/*' :{
controller : 'Web/welcomeController',
skipAssets : true
}
All others routes using like api, for ajax request. This route '/*' using just for first render page. All others render provide angularjs. And there, one of route have get parameter with dot.
http://localhost:1337/search?lat=40.714545&long=-74.007112
And I get 404 error. All this is due to the parameter skipAsset, which ignores url with the content dot.
I need to controller also skip assets resource like image, js, ect. But correctly process requests with get parameters which content dot /?lat=40.714545&long=-74.007112
Upvotes: 2
Views: 818
Reputation: 24948
skipAssets
should probably be fixed to ignore the query string. But in the meantime, you can use skipRegex
instead of skipAssets
. From the Sails.js docs on custom routes:
If skipping every URL containing a dot is too permissive, or you need a route's handler to be skipped based on different criteria entirely, you can use skipRegex. This option allows you to specify a regular expression or array of regular expressions to match the request URL against; if any of the matches are successful, the handler is skipped. Note that unlike the syntax for binding a handler with a regular expression, skipRegex expects actual RegExp objects, not strings.
So something like:
'/*' :{
controller : 'Web/welcomeController',
skipRegex : /^[^?]+\./
}
would probably be sufficient.
Upvotes: 2