跨域AJAX导致403被禁止 [英] Cross domain AJAX results in 403 forbidden

查看:1439
本文介绍了跨域AJAX导致403被禁止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在尝试通过POST进行跨域AJAX调用。如果我们直接尝试从 aaa.com 访问 bbb.com ,它将要求提供凭据。只有在提供凭证后,我们才能访问 bbb.com 。现在以相同的方式,当对另一个域进行AJAX调用时,在这种情况下 bbb.com 我收到403禁止错误。

We are trying to make cross domain AJAX call via POST. If we directly try to access bbb.com from aaa.com it will ask for credentials. Only after giving credentials will we be able to access bbb.com. Now in the same way, when an AJAX call is made to a different domain, in this case bbb.com I'm receiving a 403 forbidden error.

我尝试添加授权标题,现在在请求标题中,我看到了下面的标题,但即使在获得授权标题后我仍然遇到问题。

I tried adding the authorization header and now in the request header, I see the below headers but even after having authorization header I'm still having the issue.


接受text / html,application / xhtml + xml,application / xml; q = 0.9, / ; q = 0.8

Accept-Encoding gzip,deflate

Accept-Language en-US,en; q = 0.5

Access-Control-Request-He ... authenticationindicator,authorizationtoken

Access-Control-Request-Me ... POST

授权基本TG9uZG9uOkJiZ0JlbjE4NTk =

缓存控制无缓存

主机aaa.com

Origin bbb.com

Pragma no-cache

Proxy-Connection keep-alive

User-Agent Mozilla / 5.0(Windows NT 6.1; rv:17.0)Gecko / 20100101 Firefox / 17.0

Accept text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8
Accept-Encoding gzip, deflate
Accept-Language en-US,en;q=0.5
Access-Control-Request-He... authenticationindicator,authorizationtoken
Access-Control-Request-Me... POST
Authorization Basic TG9uZG9uOkJiZ0JlbjE4NTk=
Cache-Control no-cache
Host aaa.com
Origin bbb.com
Pragma no-cache
Proxy-Connection keep-alive
User-Agent Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/20100101 Firefox/17.0

有谁知道我们如何解决403禁止的问题?

Does anyone know how we can solve the 403 forbidden issue?

推荐答案

听起来像是Cross Origin问题 - https://developer.mozilla.org/en-US/docs/HTTP/ Access_control_CORS

Sounds like a Cross Origin issue - https://developer.mozilla.org/en-US/docs/HTTP/Access_control_CORS

您可能想要添加从bbb.com返回的标题,如下所示:

You probably want to add something the headers returned from bbb.com, like so:

Access-Control-Allow-Origin: *

Hope这有帮助,
Chris

Hope that helps, Chris

这篇关于跨域AJAX导致403被禁止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆