piano1029
03/25/2023, 3:04 PMTypeError: this.response.status is not a function
, used to work fine but now this.piano1029
03/25/2023, 3:05 PMTypeError: this.response.status is not a function
at ExpressResponse.sendJSONResponse (/usr/src/app/node_modules/supertokens-node/lib/build/framework/express/framework.js:152:31)
at sendNon200Response (/usr/src/app/node_modules/supertokens-node/lib/build/utils.js:135:9)
at Object.sendNon200ResponseWithMessage (/usr/src/app/node_modules/supertokens-node/lib/build/utils.js:126:5)
at /usr/src/app/node_modules/supertokens-node/lib/build/recipe/session/utils.js:75:17
at Generator.next (<anonymous>)
at /usr/src/app/node_modules/supertokens-node/lib/build/recipe/session/utils.js:44:75
at new Promise (<anonymous>)
at __awaiter (/usr/src/app/node_modules/supertokens-node/lib/build/recipe/session/utils.js:26:16)
at sendUnauthorisedResponse (/usr/src/app/node_modules/supertokens-node/lib/build/recipe/session/utils.js:74:12)
at Object.<anonymous> (/usr/src/app/node_modules/supertokens-node/lib/build/recipe/session/utils.js:187:30)
at Generator.next (<anonymous>)
at /usr/src/app/node_modules/supertokens-node/lib/build/recipe/session/utils.js:44:75
at new Promise (<anonymous>)
at __awaiter (/usr/src/app/node_modules/supertokens-node/lib/build/recipe/session/utils.js:26:16)
at Object.onUnauthorised (/usr/src/app/node_modules/supertokens-node/lib/build/recipe/session/utils.js:186:13)
at SessionRecipe.<anonymous> (/usr/src/app/node_modules/supertokens-node/lib/build/recipe/session/recipe.js:147:64)
at Generator.next (<anonymous>)
at /usr/src/app/node_modules/supertokens-node/lib/build/recipe/session/recipe.js:44:75
at new Promise (<anonymous>)
at __awaiter (/usr/src/app/node_modules/supertokens-node/lib/build/recipe/session/recipe.js:26:16)
at SessionRecipe.handleError (/usr/src/app/node_modules/supertokens-node/lib/build/recipe/session/recipe.js:135:13)
at SuperTokens.<anonymous> (/usr/src/app/node_modules/supertokens-node/lib/build/supertokens.js:336:64)
rp_st
03/25/2023, 3:08 PMpiano1029
03/25/2023, 5:31 PMrp_st
03/25/2023, 8:30 PMpiano1029
03/25/2023, 8:45 PMrp_st
03/25/2023, 8:47 PMpiano1029
03/25/2023, 8:49 PMrp_st
03/25/2023, 8:51 PMrp_st
03/25/2023, 8:51 PMrp_st
03/25/2023, 8:52 PMpiano1029
03/25/2023, 8:53 PMpiano1029
03/25/2023, 8:54 PMts
export async function getServerSideProps(context: GetServerSidePropsContext) {
await superTokensNextWrapper(
async (next) => {
await verifySession({ sessionRequired: true })(context.req as SessionRequest, context.res as any, next);
},
context.req,
context.res
)
let session = (context.req as SessionRequest).session;
if (session === undefined) throw new Error(`ufkc`)
let userId = session.getUserId();
rp_st
03/25/2023, 8:55 PMpiano1029
03/25/2023, 8:55 PMpiano1029
03/25/2023, 8:56 PMrp_st
03/25/2023, 8:56 PMpiano1029
03/25/2023, 8:58 PMts
import { superTokensNextWrapper } from 'supertokens-node/nextjs'
import { middleware } from 'supertokens-node/framework/express'
import { NextApiRequest, NextApiResponse } from 'next'
import { Request, Response } from 'express';
import supertokens from 'supertokens-node'
import { backendConfig } from '../../../config/backendConfig'
import NextCors from "nextjs-cors";
supertokens.init(backendConfig())
export default async function superTokens(
req: NextApiRequest & Request,
res: NextApiResponse & Response
) {
let origin = *origin mess here*
// NOTE: We need CORS only if we are querying the APIs from a different origin
await NextCors(req, res, {
methods: ["GET", "HEAD", "PUT", "PATCH", "POST", "DELETE"],
origin,
credentials: true,
allowedHeaders: ["content-type", ...supertokens.getAllCORSHeaders()],
});
await superTokensNextWrapper(
async (next) => {
await middleware()(req, res, next)
},
req,
res
)
//if (!res.writableEnded) {
// res.status(404).send('Not found')
//}
}
rp_st
03/25/2023, 8:59 PMpiano1029
03/25/2023, 9:02 PMts
import { superTokensNextWrapper } from 'supertokens-node/nextjs'
import { SessionRequest } from 'supertokens-node/framework/express'
import { verifySession } from "supertokens-node/recipe/session/framework/express";
import { NextApiRequest, NextApiResponse } from 'next'
import { Request, Response } from 'express';
import supertokens from 'supertokens-node'
import { backendConfig } from '../../config/backendConfig'
import NextCors from "nextjs-cors";
import UserMetadata from 'supertokens-node/recipe/usermetadata'
supertokens.init(backendConfig())
export default async function userData(
req: NextApiRequest & Request,
res: NextApiResponse & Response
) {
await superTokensNextWrapper(
async (next) => {
await verifySession()(req, res, next)
},
req,
res
)
const session = (req as SessionRequest).session;
if (session == undefined) {
res.status(401).send("Unauthorized")
return
}
const userId = session!.getUserId();
const { metadata } = await UserMetadata.getUserMetadata(userId);
res.json(metadata)
}
But Safari being Safari it didn't log any response info, I'll try Chromerp_st
03/25/2023, 9:03 PMrp_st
03/25/2023, 9:03 PMpiano1029
03/25/2023, 9:03 PMrp_st
03/25/2023, 9:04 PMpiano1029
03/25/2023, 9:04 PMrp_st
03/25/2023, 9:06 PMpiano1029
03/25/2023, 9:06 PMrp_st
03/25/2023, 9:07 PMpiano1029
03/25/2023, 9:08 PMrp_st
03/25/2023, 9:11 PMrp_st
03/25/2023, 9:20 PMrp_st
03/25/2023, 9:20 PMrp_st
03/25/2023, 9:21 PMpiano1029
03/25/2023, 9:33 PMif (session == undefined) {
, but after that it just fails and the client redirects to login (which is my code).rp_st
03/25/2023, 9:35 PMrp_st
03/25/2023, 9:36 PMpiano1029
03/25/2023, 9:40 PMException has occurred: Error: Session does not exist. Are you sending the session tokens in the request with the appropriate token transfer method
during login. And the request to my userdata api endpoint doesn't have any Cookies or other data attached to itrp_st
03/25/2023, 9:41 PMrp_st
03/25/2023, 9:42 PMpiano1029
03/25/2023, 9:42 PMrp_st
03/26/2023, 5:42 AM