Hacker News new | past | comments | ask | show | jobs | submit login

We just use a path prefix and a reverse proxy to save the pre-flight request altogether.



Could have other sec consequences, e.g. XSS in the API is now all of a sudden exploitable, just an example


There are solutions for that; for example, it can also be avoided in prod by having a JS-specific subdomain that's the only domain whitelisted by the CSP, separate from the main API. HTTP/2 connection pools should be recycled and simple <script> inclusions don't require CORS so I don't expect many downsides. As an added bonus, such a configuration would be easier to use in combination with a CDN.


"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?


Yes, just use. The fact that less common edge cases exist doesn't undermine the solution. The example in the article was example.com and api.example.com, the most common setup imo.

> 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.


I could be in some sort of bubble, but hardly can remember the case when dynamic part of request has not flown through some sort of reverse proxy or fully capable webserver (like Apache) anyways. On dev envs of course seen, but not in production.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: