-->

Yammer REST API CORS

2019-08-16 14:27发布

问题:

I've setup an app in Yammer and added Javascript origins but still can't make xhr request

XMLHttpRequest cannot load https://www.yammer.com/platform/login_status.json?client_id=123456789&_=123456789. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://example.com.dev:9000' is therefore not allowed access.

Any suggestion? I'm working from a local machine and having example.com.dev to resolve as localhost.

回答1:

I think the answer is in the domain name.

Use api.yammer.com instead of www.yammer.com

See for similar problem also the answer from Marco here



回答2:

No 'Access-Control-Allow-Origin' header is present on the requested resource.

You can do 2 things:

  • Ask yammer.com to allow your origin, or use a non browser HTTP request, for example with cURL.
  • If you develop an origin which is already allowed, then you should rewrite the hosts file and the webserver configuration on your dev machine, to bind the allowed origin to your dev site. Currently this is not an option, because there isn't any allow origin header sent according to the error message.

That's all you can do.



回答3:

In addition to changing the URL to be api.yammer.com be sure that you're not including any extra headers.

For example, I was accidentally including an extra header 'X-Foo-Id' and that was tripping up Yammer.