NextJS App Directory SSR issue.
a

a_tree.

over 1 year ago
Hello, I have been having trouble with getting Next.JS App Directory SSR to work properly. I've been following the documentation on https://supertokens.com/docs/thirdparty/nextjs/app-directory/protecting-route#sessions-with-server-components--pre and looked at the repository (https://github.com/supertokens/next.js/tree/canary/examples/with-supertokens/app). (I last checked these pages and followed them today, 2/9/2024) The components sessionAuthForNextJS.tsx and tryRefreshClientComponent.tsx are the same and I followed the code stated in home.tsx. Looking at my configuration files, they seem to be correct. When I attempt to log in, it works just fine and such. Then if I try to go to my dashboard, which has the SSR authentication requirement, I will first be redirected to the auth page for a moment then pushed to the home page '/'. Then every other attempt of trying to go to the dashboard will just continue to redirect me to the home page '/'. If convert the SSR pages into their client side version then it works just fine, however I want to use SSR for increased performance and user experience. I then got confused with the middleware, thinking it was part of the SSR before realizing it was only for APIs, but the middleware approach did fix my issues, until expiration occurred and I'd get a "Authentication required" message. As a temporary fix to this, the user would need to go back to the home page and then they'd be able to go to the dashboard and its sub pages. This sort of works but there are pages where users would go straight to a sub page within the dashboard, so they'd get this message often. Figuring out that the middleware was only for APIs, I went back and commented it out. I am now at square one with SSR authentication again and can't seem to figure out why I am only redirected to the home page and never allowed into my dashboard.
Hi, i have implemented custom UI with ThirdPartyEmailPassword recipe - react app. i'm getting this e...
g

gsj

almost 2 years ago
Hi, i have implemented custom UI with ThirdPartyEmailPassword recipe - react app. i'm getting this error when i try to signin/up with github.
Error: Getting userInfo failed with 401: {"message":"Bad credentials","documentation_url":"https://docs.github.com/rest"}
    at Object.originalImplementation.getUserInfo (C:\Users\gouta\supertokens-customapp\backend\node_modules\supertokens-node\lib\build\recipe\thirdparty\providers\github.js:86:23)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at Object.signInUpPOST (C:\Users\gouta\supertokens-customapp\backend\node_modules\supertokens-node\lib\build\recipe\thirdparty\api\implementation.js:35:30)
    at Object.signInUpAPI [as default] (C:\Users\gouta\supertokens-customapp\backend\node_modules\supertokens-node\lib\build\recipe\thirdparty\api\signinup.js:68:18)
    at Recipe.handleAPIRequest (C:\Users\gouta\supertokens-customapp\backend\node_modules\supertokens-node\lib\build\recipe\thirdparty\recipe.js:73:24)
    at Recipe.handleAPIRequest (C:\Users\gouta\supertokens-customapp\backend\node_modules\supertokens-node\lib\build\recipe\thirdpartyemailpassword\recipe.js:63:24)
    at SuperTokens.middleware (C:\Users\gouta\supertokens-customapp\backend\node_modules\supertokens-node\lib\build\supertokens.js:195:38)
    at C:\Users\gouta\supertokens-customapp\backend\node_modules\supertokens-node\lib\build\framework\express\framework.js:128:28
anyone faced the same issue and got it resolved kindly share the solution. thanks
Guys I am facing an issue while fetching a user through email. The auth dashboard shows the user is ...
v

vaz007.

almost 2 years ago
Guys I am facing an issue while fetching a user through email. The auth dashboard shows the user is signedUp and Auth method under Email password. If there is any other method to go through forgot password flow. In the current flow from frontend it sends a token, so it does not verify if a user is already present in the database. It just sends out the email to whatever email you provide. Frontend is used for thirdparty Following is config file import ThirdPartyEmailPassword from "supertokens-node/recipe/thirdpartyemailpassword"; export function getApiDomain() { const apiPort = process.env.REACT_APP_API_PORT || 4001; const apiUrl = process.env.REACT_APP_API_URL || `http://localhost:${apiPort}`; return apiUrl; } export function getWebsiteDomain() { const websitePort = process.env.REACT_APP_WEBSITE_PORT || 3000; const websiteUrl = process.env.REACT_APP_WEBSITE_URL || `http://localhost:${websitePort}`; return websiteUrl; } export const SuperTokensConfig: TypeInput = { supertokens: { connectionURI: "localhost:3567", }, appInfo: { appName: "Auth Middleware Express", apiDomain: getApiDomain(), websiteDomain: getWebsiteDomain(), }, recipeList: [ ThirdPartyEmailPassword.init({ providers: [ // Google({ // clientId:"ID", // clientSecret: "SECRET", // }), ], }), Session.init({}), Dashboard.init(), UserMetadata.init(), ], }; Following is my controller file import { getUsersByEmail } from "supertokens-node/recipe/thirdpartyemailpassword"; export const createTokenForResetPassword = async (req: any, res: any) => { const { email } = req.body; try { const getUser = await getUserByEmail(email); console.log("EMAIL ", email); console.log("USER ",getUser); // const createVeriToken = await createResetPasswordToken(getUser.userId); res.send({ status: "OK" }); } catch (err) { res.status(500) } };