Expressjs 解决AJAX跨域请求 (CORS)
在我的前端项目http://localhost:63342/replay.moqi.mobi/index.html 中访问expressjs的项目http://localhost:3000/blogs会出现跨域请求的问题,如下: XMLHttpRequest cannot load http://localhost:3000/blogs. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:63342' is therefore not allowed access. 关于CORS,<pro express.js>书中38页介绍如下: If you’re building an application (a REST API server) that serves requests coming from front-end clients hosted on different domains, you might encounter cross-domain limitations when making XHR/AJAX calls. In other words, browser requests are limited