相同的原始体系结构,而不是发出跨域请求

Imagine a common scenario where you have a website, hosted at https:\\www.mywebsite.com\ which needs to make requests to a backend.

If the server is hosted on a slightly different origin (i.e. different subdomain, port, etc.) the browser will trigger a CORS request. For example if the server was at https:\\apis.mywebsite.com\....

I am wondering, therefore, if it would make sense to expose server-side endpoints on the same origin but on a different path, perhaps somewhere such as https:\\www.mywebsite.com\apis\....

这可以通过代理服务器轻松实现,我想这在托管网站时无处不在,并且无需完全处理CORS。

是否有强烈的反对意见?另外,您知道有任何网站可以作为参考吗?

评论