小编MaK*_*MaK的帖子

safari上的跨域$ .ajax和302重定向

我正在进行跨域$ .ajax调用设置

$.ajax({
    url         : 'http://example.com/somepage',
    type        : 'get',
    crossDomain : true,
    xhrFields   : { withCredentials: true },
    success     : function(data) {
        // do something with data
    }
});
Run Code Online (Sandbox Code Playgroud)

和vhost conf上的服务器端

SetEnvIfNoCase ORIGIN (.*) ORIGIN=$1
Header set Access-Control-Allow-Origin "%{ORIGIN}e"
Header set Access-Control-Allow-Methods "post, get, put, options, patch, delete"
Header set Access-Control-Allow-Headers "origin, x-requested-with, content-type"
Header set Access-Control-Max-Age "60"
Header set Access-Control-Allow-Credentials true
Run Code Online (Sandbox Code Playgroud)

除非我的http://example.com/somepage使用302代码重定向到另一个页面http://example.com/someotherpage,在这种情况下,即ff,chrome和opera正在运行并返回从重定向到页面的数据,但不是safari我可以看到重定向(safari控制台),但重定向后的第二次调用中止.

有任何想法吗 ?

safari ajax jquery redirect cross-domain

7
推荐指数
1
解决办法
1204
查看次数

nodejs:使用http-proxy的路由表

尝试使用http-proxy 1.4.3安装带有自定义路由逻辑的http代理,在此tuto之后执行以下代码:

var httpProxy = require("http-proxy");
var url = require("url");

httpProxy.createServer(function(req, res, proxy) {

    var hostname = req.headers.host.split(":")[0];
    var pathname = url.parse(req.url).pathname;

    // Options for the outgoing proxy request.
    var options = { host: hostname };

    // Routing logic
    if(hostname == "127.0.0.1") {
        options.port = 8083;
    } else if(pathname == "/upload") {
        options.port = 8082;
        options.path = "/"; 
    } else {
        options.port = 8081;
    }
    // (add more conditional blocks here)

    proxy.proxyRequest(req, res, options); …
Run Code Online (Sandbox Code Playgroud)

node.js node-http-proxy

5
推荐指数
1
解决办法
6803
查看次数