Angular Development - API Server doesn't accept requests because of a missing XSRF Token

Hello everyone,

so i set up a angular development projekt using a local API server.

The API Server doesn't accept Requests because of a missing XSRF Token. 

When I look into the Development Tools, it tells me that the browser doesn't accept incomming  cookies because of a mismatched domain. 

Which is understandable since the cooke is sent with /APIServer as Path while the API Server runs locally under http://localhost:8182

(hence no XSRF Token set on the browser, hence no XSRF Token sent back) 

How do I fix this issue?

Greetings

Ivo Burkatzki

Parents Reply Children
  • This will not work at all regardless of the cookie path, because your Angular frontend will typically run on HTTP (no "S") and cannot access cookies from a secure context. The browsers will not allow it.

    In Chrome's F12 tools --> network tab, you can see this happening. By filtering on "blocked cookies" you can see if any cookies were blocked, and the browser will show the reason why.

    We've had some success going HTTPS all the way, which means that your local Angular server needs to run in HTTPS. But it's probably not worth the hassle as long as you are in a development (non-production) environment, where it may be acceptable to just disable XSRF protection.