redirect() not possible due to CORS
feresr opened this issue · 1 comments
feresr commented
Examples use redirect()
but this is not possible due to CORS not being supported by Twitter https://stackoverflow.com/a/35898961
Actual behavior
Access to fetch at 'https://twitter.com/i/oauth2/authorize?state=<redacted>&code_challenge_method=s256&client_id=<redacted>&scope=<redacted>&response_type=code&redirect_uri=<>&code_challenge=<> (redirected from 'http://localhost:3000/api') from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
Steps to reproduce the behavior
Implement example https://github.com/twitterdev/twitter-api-typescript-sdk/blob/0d12a20a76d6dd9c346decf9cc80bc611975d43f/examples/oauth2-callback_pkce_s256.ts#L39
feresr commented
Using window.location.href = "/my-login-endpoint";
instead of fetch("/my-login-endpoint")
fixed my issue