Sails version: 0.12.2
Node version: 5.10.0 & 4.3.1
NPM version: 3.8.5 & 2.14.6
Operating system: Mac OSX 10.11.3
On 0.12.1 the following allowed me to access my routes starting /api without rendering a view but on 0.12.2 it now renders the view
module.exports.routes = {
'/*': {
view: 'homepage',
skipAssets: true,
skipRegex: /(^\/api\/.*$)|^\/csrfToken$/
}
};
Hi @dottodot! It looks like you missed a step or two when you created your issue. Please edit your comment (use the pencil icon at the top-right corner of the comment box) and fix the following:
As soon as those items are rectified, post a new comment (e.g. “Ok, fixed!”) below and we'll take a look. Thanks!
_If you feel this message is in error, or you want to debate the merits of my existence (sniffle), please contact [email protected]._
OK Fixed
@dottodot Yep. I only use the following for my single page application:
'/*': {
view: 'homepage',
skipAssets: true
}
I believe skipAssets is broken transitioning from 0.12.1 to 0.12.2.
+1. It's definitely broken. I used to use regExp too. Things work fine except Assets in version 0.12.5 They are not loaded property - wrong type.
_Resource interpreted as Stylesheet but transferred with MIME type text/html_
"r|^\/(?!.*api).*|":{
view: 'homepage',
skipAssets: true
}
But in 0.11.5 everything is fine.
@nikhilbedi @AlexanderKozhevin @dottodot Thanks for the report guys. Looking into it momentarily.
Verified on Node 4 (repro). I've got a general idea of what might be going on, but I want to add a few tests first just to make sure (and to avoid any future regressions). We'll release a follow-up patch ASAP this morning.
@nikhilbedi @AlexanderKozhevin @dottodot Thanks again for your help!
Confirmed that skipAssets and skipRegex are currently working with controller+action route targets; the issue is specifically with view targets. Should have a fix ready momentarily.
So the issue here was that when the view hook was changed to solve issues with explicit routing to deeply nested static views, core options were no longer being passed through from the view hook, causing core options like skipAssets and skipRegex to be ignored (since they weren't passed back to .bind()).
These options were already well tested for controllers+actions, but there weren't yet tests in core for direct routing to views (i.e. using {view: 'foo/bar'} route target syntax). The issue is now resolved, and I added new tests that specifically check for this case to ensure there aren't regressions. Will publish [email protected] with this included momentarily.
Fix published in [email protected]:
npm install sails@latest --save --save-exact
Most helpful comment
Fix published in [email protected]: