I have a REST backend running on localhost:8080 that issues a cookie when the user logs in. I have a Angular2 front end packaged in with the backend. When I run the project, angular sends the cookie and attaches the custom header to the requests to the backend. However, when I run the front end using the list server one localhost:3000, angular does not send any cookies and does not attach the custom header.
Request when running with backend:
Accept:application/json, text/plain, */*
Accept-Encoding:gzip, deflate, sdch, br
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Cookie:io=8Dk6ajOQZyDz-bvXAAAB; jwt=eyJh...H1aCccT2U
Host:localhost:8080
Referer:http://localhost:8080/
User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.76 Safari/537.36
X-CSRF-Token:2c8744ff-38ad-49cb-bf07-fe75cd16f827
Running with lite-server and apache2
Accept:*/*
Accept-Encoding:gzip, deflate, sdch, br
Accept-Language:en-US,en;q=0.8
Access-Control-Request-Headers:x-csrf-token
Access-Control-Request-Method:GET
Connection:keep-alive
Host:localhost:8080
Origin:http://localhost:3000
Referer:http://localhost:3000/
User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.76 Safari/537.36
From what I read, cookies are not port specific, and therefore should be sent with a request from localhost:3000 and localhost:8080.
I have a CORS filter on the backend to accept all requests from any origin.
- Why aren't headers being attached?
- Why aren't the cookies being attached?