I made a little app to test how a twitter login would work serverless. I use PassportJS and store the sessions on MongoDB.
The app works but there is one key part that I couldn’t fix. After clicking the login button and waiting for the redirect to the homepage the tokens from the twitter API appear in the search bar: https://serverless-twitter-login.netlify.app/?oauth_token=xyz&oauth_verifier=xyz
(By redirect I mean the redirects in node.js and not redirect in the netlify.toml. I used a redirect in the netlify.toml before, but I removed it and hoped this fixes the issue - but it didn’t)
Hi @coelmay I’m not trying to send data. I change the form to links so it is probably more clear. (it still doesn’t work) <a href="/.netlify/functions/auth/login">Login</a>
I’m also not using Express…
Yes this router uses get. But how would this fix my problem if I changed it to a post? I’m not trying to send data to this route.
The purpose of the following snippet is to retrieve the user data when the user is logged in. (this works) So I don’t think a post here would solve the problem.
Thanks for your investigation. I think the snippet is valid. The problem seems to be netlify’s feature “automatic pass through of query string parameters”, which preserves ?oauth_token=xyz&oauth_verifier=xyz after the redirect from twitter.
I now use this config to remove the params:
[[redirects]]
from = "/*"
to = "/?success"
query = {oauth_token = ":token", oauth_verifier = ":verifier"}
force = true