supertokens / supertokens-node

Node SDK for SuperTokens core
https://supertokens.com
Other
287 stars 76 forks source link

Http redirects not working with Fastify for Android Webviews #707

Open nkshah2 opened 10 months ago

nkshah2 commented 10 months ago

The default API implementation for Apple redirect post includes the following code:

options.res.setHeader("Location", urlObj.toString(), false);
options.res.setStatusCode(303);
options.res.sendHTMLResponse("");

This way of redirecting does not work with Fastify (tested on Android webviews).

FastifyReply exposes a method called redirect that does work properly. A good way to solve this is to add another method to BaseResponse for redirection that can use framework default methods of doing redirects wherever possible.

All instances in code where we manually redirect should then also use this function

nkshah2 commented 10 months ago

For anyone following this issue, this has been added to the pipeline and will be prioritised if enough people run into this issue. In the meantime if you do run into this issue you can use the original FastifyReply object to redirect using their helper function by overriding the apple redirect API

Inside your override you can access the response object

options.res.original.redirect(url)