LinkedIn 分享 API 失败 "Response to preflight request doesn't pass"

LinkedIn share API fails with "Response to preflight request doesn't pass"

我正在使用 api 调用在公司页面上分享 post ,当我从本地主机执行此操作时它工作正常,但是当我将它放在实时 VPS 上时它失败了

Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin "MY ADDRESS I REMOVED FOR MY SECURITY" is therefore not allowed access.

我用谷歌搜索了一下,发现它是 CORS headers 的问题,我尝试在我设置的 .htaccess 中添加 Header set Access-Control-Allow-Origin "*" 但仍然没有,任何和所有指针或修复将不胜感激,谢谢

我使用 php 5.6 和 apache 2.4.18

将此添加为答案以便任何人都可以找到它。正如@HoldOffHunger 所建议的那样。 好的,我设法通过将 headers 添加到 .htaccess 和我的 ajax 调用来修复此错误并且它正在工作,所以如果您有相同的错误通过添加 Access-Control-Allow-Origin "*" headers 在 ajax 调用中,将“*”更改为您的来源。