https://supertokens.com/ logo
#support-questions
Title
# support-questions
p

paras

02/23/2023, 4:12 AM
Can anyone please help me out? I was trying to protect the frontend rout of my own ui, using usestate by doesSessionExists, but then it says that particular route doesn't exist. But the same route works fine without it
r

rp

02/23/2023, 5:28 AM
hey @paras can you elaborate on your question? Maybe share some code?
p

paras

02/24/2023, 4:25 AM
import React, { useEffect, useState } from 'react' import '../node_modules/bootstrap/dist/css/bootstrap.min.css' import './App.css' import SuperTokens from 'supertokens-web-js'; import { BrowserRouter as Router, Routes, Route, Link , useNavigate} from 'react-router-dom' import Login from './components/login.component' import SignUpComponent from './components/signup.component' import { SuperTokensConfig } from "./config"; import Session from "supertokens-web-js/recipe/session"; import HomePage from './components/homepage.component'; SuperTokens.init(SuperTokensConfig); function App() { const [isAuthenticated, setIsAuthenticated] = useState(false); const sessionExist = async() =>{ if (await Session.doesSessionExist()) { // user is logged in setIsAuthenticated(true); } else { // user has not logged in yet setIsAuthenticated(false); } }; useEffect( () => {sessionExist()}, []);
return ( Frontend2 Login Sign up <Route path="/auth" element={} /> <Route path="/auth/sign-in" element={} /> <Route path="/auth/sign-up" element={} /> {/* <Route path="/auth/homepage" element={} /> */} <Route path={isAuthenticated?"/auth/homepage":"/auth/sign-in"} element={isAuthenticated?:} /> ) } export default App
using this code in App.tsx, I was trying to protect /auth/homepage rout, but it gives error as shown in ss above
r

rp

02/24/2023, 6:25 AM
there is no
/auth/homepage
route that we have.
please see our docs / guides in more detail.
p

paras

02/25/2023, 5:05 AM
Am using my own UI, and thus created a route for that, this route works fine when I am not protecting it
r

rp

02/25/2023, 5:37 AM
ah right. So the issue is with how you are using the Route component - i don't think you can dynamically change the route path like
path={isAuthenticated?"/auth/homepage":"/auth/sign-in"}
p

paras

02/27/2023, 4:51 AM
ooh okk, lemme check it than thanks
but am getting Server Error at localhost:5225 and the logs are as: Using engine: sql. Type: postgres [next-auth][error][NO_SECRET] https://next-auth.js.org/errors#no_secret Please define a
secret
in production. MissingSecret [MissingSecretError]: Please define a
secret
in production. at assertConfig (/app/node_modules/next-auth/core/lib/assert.js:24:14) at NextAuthHandler (/app/node_modules/next-auth/core/index.js:34:52) at NextAuthNextHandler (/app/node_modules/next-auth/next/index.js:20:51) at /app/node_modules/next-auth/next/index.js:56:38 at Object.apiResolver (/app/node_modules/next/dist/server/api-utils/node.js:182:15) at runMicrotasks () at processTicksAndRejections (node:internal/process/task_queues:96:5) at async NextNodeServer.runApi (/app/node_modules/next/dist/server/next-server.js:386:9) at async Object.fn (/app/node_modules/next/dist/server/base-server.js:488:37) at async Router.execute (/app/node_modules/next/dist/server/router.js:228:32) { code: 'NO_SECRET' } [next-auth][error][NO_SECRET] https://next-auth.js.org/errors#no_secret Please define a
secret
in production. MissingSecret [MissingSecretError]: Please define a
secret
in production. at assertConfig (/app/node_modules/next-auth/core/lib/assert.js:24:14) at NextAuthHandler (/app/node_modules/next-auth/core/index.js:34:52) at NextAuthNextHandler (/app/node_modules/next-auth/next/index.js:20:51) at /app/node_modules/next-auth/next/index.js:56:38 at Object.apiResolver (/app/node_modules/next/dist/server/api-utils/node.js:182:15) at runMicrotasks () at processTicksAndRejections (node:internal/process/task_queues:96:5) at async NextNodeServer.runApi (/app/node_modules/next/dist/server/next-server.js:386:9) at async Object.fn (/app/node_modules/next/dist/server/base-server.js:488:37) at async Router.execute (/app/node_modules/next/dist/server/router.js:228:32) { code: 'NO_SECRET' }
r

rp

02/28/2023, 10:52 AM
this is nothing to do with supertokens
p

paras

02/28/2023, 10:53 AM
okk, sure