-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error fetching crsf token with sails and ember on different host #11
Comments
Using the socket adapter, I get the following issue (csrf value is
That may be the same underlying issue but I'm still looking into it as there is no explicit debug available out of the box for this one. Thanks! |
ping @huafu ;) |
I got some time to look into it. For SailsRESTAdapter, I fixed it by building the url using the original RESTAdapter mixin: replaced
This is strange because my cors is enabled for As for the SailsSocketAdapter, it doesn't seem to be related since it goes to sails through the socket service. But i'm still getting a When all is ok, I can submit a PR for the fix of the SailsRESTAdapter if you want. This affect all url based settings such as host and namespace. |
Sorry, got a deadline and had to work hard on another project ;-) Now on this! |
Ahah no problem. Been there 😛 |
@tibotiber can you test with Please lemme know if it is ok, then I'll tag the version and publish it to npm so that you can use |
I'm still having the |
I actually had the same issue locally. I created a bare new project and asked you to test because I thought I miss configured something on the sails side and got no time to dig into it. The new message you see is just some more helpful information that I added. What happen is that sails returns a correct response (2xx) when asking for the CSRF token on |
Yeah exactly my feeling as well. Thanks again for your help. Will look into this more when i get some time and submit to sailsjs as you recommend. |
Hi @huafu, I finally got it. From sails' csrf config doc, csrf is normally activated by setting
Maybe you can put a note on this in the README? |
Thanks, v0.0.15 released and published ;-) |
@tibotiber any chance you could provide an example of your working CSRF setup between Ember and Sails? I keep getting a Thanks! |
@jamesdixon if I don't miss anything, I'm having on sails side: // config/csrf.js
module.exports.csrf = {
routesDisabled: '/auth/login,/auth/logout,/users/jwt,/upload',
origin: 'http://b2d:32769'
};
// config/blueprints.js
pluralize: true, On Ember side, I'm using v0.0.15 with the following: // config/environment.js
/* config for ember-data-sails */
ENV.APP.SAILS_LOG_LEVEL = 'debug';
ENV.APP.emberDataSails = {
host: 'https://dev.planecq.com:1337',
scriptPath: '/js/dependencies/sails.io.js'
};
// allow to fetch the script
ENV.contentSecurityPolicy['script-src'] += ' https://dev.planecq.com:1337';
// allow the websocket to connect
ENV.contentSecurityPolicy['connect-src'] += ' https://dev.planecq.com:1337 wss://dev.planecq.com:1337';
/* end of config for ember-data-sails */ // app/adapters/application.js
import SailsSocketAdapter from 'ember-data-sails/adapters/sails-socket';
export default SailsRESTAdapter.extend({
useCSRF: true,
coalesceFindRequests: true
}); |
@tibotiber thanks for this! Unfortunately, I'm still having issues. Are you doing any requests outside of what's done by Ember Data? For example, my authentication uses Cheers, |
Hi. Thanks again for the work.
It seems your REST adapter is trying to fetch a csrf token from the ember host, not the sails host. GET requests are ok but as soon as I POST, I get
and
...:4200
is my ember host, sails is on...:1337
.The text was updated successfully, but these errors were encountered: