supertokens-node icon indicating copy to clipboard operation
supertokens-node copied to clipboard

Http redirects not working with Fastify for Android Webviews

Open nkshah2 opened this issue 2 years ago • 1 comments

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 avatar Oct 05 '23 07:10 nkshah2

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)

nkshah2 avatar Oct 06 '23 06:10 nkshah2