CORS = Cross-Origin Resource Sharing. There, that wasn't so hard, was it? I assume this is written for web developers who find this the most familiar acronym in the world, but ... still, it would not kill anybody to include the definition of the acronym, perhaps even with a friendly link [1] to make it Even More Accessible. I'll be off looking at the lawn mowing robot, now. [1]: https://developer.mozilla.org/en-US/do…
In the web development world CORS is as common an acronym as REST or TCP. I sympathise with the endless need to look up acronyms but in my view anyone involved enough with web to need the above advice would (or should) know the acronym. I do appreciate your point of view, but inclusiveness shouldn't come at the cost of brevity when those who would be included wouldn't benefit from it.
Cache your CORS
31–40 of 118 posts
Re: Cache your CORS
#32Re: Cache your CORS
#33Unfortunately this caching is still per-path. For example: GET /v1/document/{document-id}/comments/{comment-id} For every new document-id or comment-id, there will be a new pre-flight request. Alternative hacks: Offer a variant of your API format that either 1. Moves the resource path to the request body (or to a header that is included in "Vary"). Though the rest of your stack (load balancing, observability, redacti…
Re: Cache your CORS
#34Re: Cache your CORS
#35Unfortunately this caching is still per-path. For example: GET /v1/document/{document-id}/comments/{comment-id} For every new document-id or comment-id, there will be a new pre-flight request. Alternative hacks: Offer a variant of your API format that either 1. Moves the resource path to the request body (or to a header that is included in "Vary"). Though the rest of your stack (load balancing, observability, redacti…
3. Don't allow cross-platform requests in the first place; have your API consumers go through a server-side proxy on the same domain instead, or host it on the same domain in the first place.
Re: Cache your CORS
#36Doesn't moving the API from the subdomain to the /api path on the same subdomain as the website solve the problem?
Re: Cache your CORS
#37We just use a path prefix and a reverse proxy to save the pre-flight request altogether.
What if the API is shared between multiple domains? Do you need to reverse proxy it everywhere?
What if it is a public API for third-party sites?
Re: Cache your CORS
#38We just use a path prefix and a reverse proxy to save the pre-flight request altogether.
"just use"! What if the API is shared between multiple domains? Do you need to reverse proxy it everywhere? What if it is a public API for third-party sites?
> What if the API is shared between multiple domains? Do you need to reverse proxy it everywhere?
It would depend on your specific setup. We use a single nginx server entry to proxy many domains.
> What if it is a public API for third-party sites?
Then this approach would not be viable.
Re: Cache your CORS
#39Access-Control-Max-Age has, unfortunately a big security caveat which is that it is cached on a per-endpoint basis. Because Access-Control-Allow-Origin only allows one origin specification, if you previously used the Origin header to determine who could access the API, your next API requestor will effectively get your last response. For example, to allow abc.com AND bcd.com, you could check Origin and if correct retu…
Re: Cache your CORS
#40Unfortunately this caching is still per-path. For example: GET /v1/document/{document-id}/comments/{comment-id} For every new document-id or comment-id, there will be a new pre-flight request. Alternative hacks: Offer a variant of your API format that either 1. Moves the resource path to the request body (or to a header that is included in "Vary"). Though the rest of your stack (load balancing, observability, redacti…
JMAP is very well suited to CORS due to this: https://www.rfc-editor.org/rfc/rfc8620.html