I personally always thought that the CORS domain checking was needlessly and overly restrictive. I can understand entirely different top-level domains; definitely 100% necessary. You start to lose me at different sub-domains for the same top-level domain. Do we really need to check api.example.com from app.example.com ? Chances are good that they're both controlled by the same entity, so what's the problem? I'm out t…
> Do we really need to check api.example.com from app.example.com? Sure. What about hosted subdomains where people can create their own sites, with JS, on different subdomains? CORS can't work without applying the most restrictive policy by default -- if you do care about these things being able to access each other, send Access-Control headers.
Killing CORS Preflight Requests on a React SPA
21–30 of 54 posts
Re: Killing CORS Preflight Requests on a React SPA
#22> In terms of security, all API calls should be using https and there is little difference in putting the token in headers or as part of the query string. Mostly true. But as a heads up, you might want to shy away from this as plenty of browser extensions are actually spyware and report full URLs back to the mothership. We ran into this recently where calls to our service including API keys in the query parameters en…
I wish browser vendors would put work into making the browser-managed client certificate UX much nicer. That would make it possible to offer a real step change in security.
Re: Killing CORS Preflight Requests on a React SPA
#23Earlier quoted context omitted.
I wish browser vendors would put work into making the browser-managed client certificate UX much nicer. That would make it possible to offer a real step change in security.
This is about authenticating consumers of an API, not end users. So while your wish is nice, it's a non sequitur here.
Re: Killing CORS Preflight Requests on a React SPA
#24Re: Killing CORS Preflight Requests on a React SPA
#25Yeeaahh.... Putting auth tokens in GET parameters is more 1999 than 2016. Please don't do it, its not smart.
Re: Killing CORS Preflight Requests on a React SPA
#26Earlier quoted context omitted.
> Do we really need to check api.example.com from app.example.com? Sure. What about hosted subdomains where people can create their own sites, with JS, on different subdomains? CORS can't work without applying the most restrictive policy by default -- if you do care about these things being able to access each other, send Access-Control headers.
Then request to add yourself to the public suffixes list.
Re: Killing CORS Preflight Requests on a React SPA
#27Earlier quoted context omitted.
> Do we really need to check api.example.com from app.example.com? Sure. What about hosted subdomains where people can create their own sites, with JS, on different subdomains? CORS can't work without applying the most restrictive policy by default -- if you do care about these things being able to access each other, send Access-Control headers.
Then request to add yourself to the public suffixes list.
Re: Killing CORS Preflight Requests on a React SPA
#28super minor but unless I'm mistaken SPA stands for "Single Page Application", so the first sentence in the post is a bit jarring: > AlphaSights’ recruitment platform evolved from a Rails application into a _classic SPA app_. Update 20s later: is "Wepack" in the diagram supposed to be "Webpack"? Update 60s later: Can you explain _what_ you're actually using that runs into CORS issues? Are browsers talking to the api.*…
The diagram is bad, the browser is running code loaded on app.* and making requests to api.*; I've used similar setups and have run into the same issues the author is describing.
Re: Killing CORS Preflight Requests on a React SPA
#29Maybe this is obvious, but why not just configure a reverse proxy to point different paths to different backends? I always assumed CORS was more for connecting directly to 3rd party APIs.