私のアプリ ( ) は、テスト目的でローカル API にプロキシするhttp://localhost:8099
CORS 要求を実行しています。これはで達成できますか?https://api.parse.com/
http://localhost:8077
grunt-connect-proxy
これは私の期待どおりに機能しない grunt-connect-proxy の設定です。
connect: {
dev: {
options: {
port: 8099,
hostname: 'localhost',
base: 'build/',
livereload: false,
keepalive: true,
middleware: function (connect, options) {
var proxy = require('grunt-connect-proxy/lib/utils').proxyRequest;
return [
// Include the proxy first
proxy,
// Serve static files.
connect.static('build/')
];
}
}
},
proxies: [
{
context: ['api/'], //same domain api requests, proxy works fine!
host: 'localhost',
port: 8077
},
{
context: ['api.parse.com/'], //cors, proxy is not working
host: 'localhost',
port: 8077,
changeOrigin: true
}]
}
→ grunt serve
Proxy created for: api/ to localhost:8077
Proxy created for: api.parse.com/ to localhost:8077
したがって、基本的にプロキシはapi/
リクエスト (同じドメイン) に対しては機能しますが、へのコア リクエストに対しては完全に無視されますapi.parse.com/
。アイデア?