Skip to content

Conversation

@diurnalist
Copy link
Contributor

This changes the behavior of resolving a permalink. Before, the
public-api would send a 302 redirect to the browser, which would then
follow that, eventually returning a 200 with a JSON payload of the
resource (if found.)

However, this was a problem for Safari 7+ (though I can't find a
documented bug for it.) Safari was not transparently following the
redirect on the simple CORS request. The reason is unclear; the origin
of the redirected-to host is the same as the original request host, and
it's a simple request (GET), with no additional headers that would
trigger the preflight1. As if to support that this is a bug, Chrome and
Firefox both do not perform a preflight request before following the
redirect.

Since this is difficult to work around on the user agent itself, we'll
have to use an out provided by the api and map the 302 code to a 200.
We still get the redirect location in the JSON payload, so we can use
that (and in fact, we already had support for this.)

Performing the 'redirect' client-side causes the request to be made
using a simple CORS request, as it should be done.

Fixes #27

This changes the behavior of resolving a permalink. Before, the
public-api would send a 302 redirect to the browser, which would then
follow that, eventually returning a 200 with a JSON payload of the
resource (if found.)

However, this was a problem for Safari 7+ (though I can't find a
documented bug for it.) Safari was not transparently following the
redirect on the simple CORS request. The reason is unclear; the origin
of the redirected-to host is the same as the original request host, and
it's a simple request (GET), with no additional headers that would
trigger the preflight[1]. As if to support that this is a bug, Chrome and
Firefox both do _not_ perform a preflight request before following the
redirect.

Since this is difficult to work around on the user agent itself, we'll
have to use an out provided by the api and map the 302 code to a 200.
We still get the redirect location in the JSON payload, so we can use
that (and in fact, we already had support for this.)

Performing the 'redirect' client-side causes the request to be made
using a simple CORS request, as it should be done.

[1]: https://www.w3.org/TR/cors/#cross-origin-request-with-preflight-0
@diurnalist diurnalist merged commit b158d77 into master Jun 9, 2016
@diurnalist diurnalist deleted the disallow-redirect-on-resolve branch June 9, 2016 14:33
@diurnalist
Copy link
Contributor Author

Published as soundcloud@3.1.2 on npm, and https://connect.soundcloud.com/sdk/sdk-3.1.2.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants