CORS

CORS is a security measure that prevents making client-side HTTP requests to any server besides the one that served the executing JavaScript. If localhost serves upapp.js, then app.js can’t make HTTP requests of any server except localhost. Some servers whitelist domains, allowing them to make such cross-origin requests, but many don’t.

One way of dealing with this involves a “reverse proxy" — that is, forwarding requests through your backend to the database, where you hit a particular endpoint for your backend, and the backend just passes the same request along to the database. Here’s how to do it in Express, using request:

http://www.ruanyifeng.com/blog/2016/04/cors.html

廣告
本篇發表於 Uncategorized。將永久鏈結加入書籤。

發表迴響

在下方填入你的資料或按右方圖示以社群網站登入:

WordPress.com Logo

您的留言將使用 WordPress.com 帳號。 登出 / 變更 )

Twitter picture

您的留言將使用 Twitter 帳號。 登出 / 變更 )

Facebook照片

您的留言將使用 Facebook 帳號。 登出 / 變更 )

Google+ photo

您的留言將使用 Google+ 帳號。 登出 / 變更 )

連結到 %s