Origin is not allowed by Access-Control-Allow-Origin

后端 未结 18 3008
北海茫月
北海茫月 2020-11-21 05:52

I\'m making an Ajax.request to a remote PHP server in a Sencha Touch 2 application (wrapped in PhoneGap).

The response from the server is the following:

18条回答
  •  既然无缘
    2020-11-21 06:03

    When you receive the request you can

    var origin = (req.headers.origin || "*");
    

    than when you have to response go with something like that:

    res.writeHead(
        206,
        {
            'Access-Control-Allow-Credentials': true,
            'Access-Control-Allow-Origin': origin,
        }
    );
    

提交回复
热议问题