javascript - Cross-Subdomain Requests - Stack Overflow

I have two URLs:One is the application URL = One is the application API URL = How can I get the appli

I have two URLs:

One is the application URL = One is the application API URL = /

How can I get the application to be able to request things from the api at a different subdomain.

I have already tried putting Access-Control-Allow-Origin: * on both sides with no luck.

Thanks

I have two URLs:

One is the application URL = http://domain./app One is the application API URL = http://api.domain./

How can I get the application to be able to request things from the api at a different subdomain.

I have already tried putting Access-Control-Allow-Origin: * on both sides with no luck.

Thanks

Share Improve this question asked Jun 22, 2012 at 17:48 JeffJeff 9432 gold badges10 silver badges17 bronze badges 1
  • It might help : stackoverflow./a/11072639/705773 – Ajinkya Commented Jun 22, 2012 at 17:50
Add a ment  | 

2 Answers 2

Reset to default 5

The two servers (not the client) need to send the following headers:

  1. Access-Control-Allow-Origin : Decide which origin could call into the server
  2. Access-Control-Allow-Methods : The method that is allowed to access the resource (GET or POST)
  3. Access-Control-Max-Age : How long the cache is held

You could inspect the headers returned from the server (using Firebug or others) if the servers are supporting cross origin resource sharing.

If you can't modify the two servers to add the headers, one other possibility to set up a proxy that sit between your request and two servers. This proxy could add the headers if you need to access them

If you own admin right to the servers, this CORS page shows how to add the headers in various platforms.

set the cookie domain to .domain. and you should be all set.. This is what I have done in my application..

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744389511a4571835.html

相关推荐

  • javascript - Cross-Subdomain Requests - Stack Overflow

    I have two URLs:One is the application URL = One is the application API URL = How can I get the appli

    7天前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信