我試圖在向Node Node服務器下訂單後重定向到支付網關,但是我的瀏覽器都沒有讓我。Node.js表示重定向到遠程URL一直失敗(CORS)
這是我的代碼,它直接來自我的付款服務的代碼示例。
res.writeHead(302, { Location : payment.getPaymentUrl() });
res.end();
總是導致:
XMLHttpRequest cannot load https://www.mollie.com/payscreen/pay/CtcH7nkDQr. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:1337' is therefore not allowed access.
我已經配置了我的應用程序使用有頭:
app.use(function (req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS');
res.header("Access-Control-Allow-Headers", "X-Requested-With");
res.header("Access-Control-Allow-Headers", "Content-Type");
res.header("Access-Control-Max-Age", "3600");
next();
});
當我在瀏覽器中訪問https:// www.mollie.com/payscreen/pay/CtcH7nkDQr',然後檢查Chrome Developer Tools網絡選項卡中的標題時,我看不到任何這些標題。下面是我得到的完整標題:HTTP/1.1 200 OK 服務器:nginx 日期:2015年2月24日星期二00:46:24 GMT 內容類型:text/html內容長度:2142 連接:keep- alive Strict-Transport-Security:max-age = 15552000 X-XSS-Protection:1;模式=塊 X-Frame-Options:DENY Vary:Accept-Encoding 內容編碼:gzip X-Whom:dc1-web-3它實際上似乎是nginx,甚至不是nodejs。也許? – Markasoftware 2015-02-24 00:47:04