supertokens-node
supertokens-node copied to clipboard
Http redirects not working with Fastify for Android Webviews
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
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)