mercredi 23 septembre 2015

ember development server code not passing cookies to my api while production build does

I have a rest API running on localhost:8001/my_app/api/, and I have apache setup to reverse proxy localhost/my_app/api/(.*) -> localhost:8001/my_app/api/\1. That's working fine.

My api expects both my csrftoken cookie and a X-CSRFToken HTTP header. I've configured my adapters/application.js to always spit out this extra header no problem. In order to have permissions to do anything with the api, it's also expecting my session cookie.

If I do a ember build -prod and copy the contents of the dist dir to apache's /var/www/myApp/, I can then successfully run my app from http://localhost/myApp/. This build, deploy, refresh my browser is a really slow and tedious process though.

If I try to use ember serve I'm getting 403 errors from my api. It turns out that while the X-CSRFToken header is being sent the csrftoken and session cookies aren't. If I look in my chrome developer tools, it shows that I have both cookies - they simply aren't in the request headers. They're both from localhost, so I'm a bit confused.

I've played around with ember serve --proxy http://localhost:80/my_app/api and ember server --proxy http://localhost:8001/my_app/api but I haven't had any luck. I'm not sure that's the issue though.

Could someone please explain to me how to get the ember-cli development server to properly access my rest api?




Aucun commentaire:

Enregistrer un commentaire