yujonglee
08/09/2023, 11:58 AMpages/api/auth/[[...path]].tsx
and it's content is same as doc.
This is my appInfo
export const appInfo = {
appName: NAME,
apiDomain: DOMAIN,
websiteDomain: DOMAIN,
apiBasePath: "/api/auth",
websiteBasePath: "/auth"
}
I can see UI in <DOMAIN>/auth
, but when I provide phone number and click continue, I got this.
[Error] Failed to load resource: the server responded with a status of 405 (Method Not Allowed) (refresh, line 0) <DOMAIN>/api/auth/session/refresh
[Error] Failed to load resource: the server responded with a status of 405 (Method Not Allowed) (refresh, line 0)
<DOMAIN>/api/auth/session/refresh
[Error] Failed to load resource: the server responded with a status of 405 (Method Not Allowed) (refresh, line 0)
<DOMAIN>/api/auth/session/refresh
[Error] Failed to load resource: the server responded with a status of 405 (Method Not Allowed) (code, line 0)
<DOMAIN>/api/auth/signinup/code
rp_st
08/09/2023, 11:59 AMyujonglee
08/09/2023, 12:02 PMsuperTokensNextWrapper
handles session/refresh
and signinup/code
?
I am bit confused because it is clear that I have /api/auth
route, but not /api/auth/session/refresh
and /api/auth/signinup/code
This is my pages/api/auth/[[...path]].tsx
ts
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"
supertokens.init(backendConfig())
export default async function superTokens(
req: NextApiRequest & Request,
res: NextApiResponse & Response
) {
await superTokensNextWrapper(
async (next) => {
// This is needed for production deployments with Vercel
res.setHeader(
"Cache-Control",
"no-cache, no-store, max-age=0, must-revalidate"
);
await middleware()(req, res, next)
},
req,
res
)
if (!res.writableEnded) {
res.status(404).send("Not found")
}
}
rp_st
08/09/2023, 12:02 PMrp_st
08/09/2023, 12:02 PMsuperTokensNextWrapper
and see if it gets loggedyujonglee
08/10/2023, 3:28 AMyujonglee
08/10/2023, 3:29 AMTypeError: Cannot read properties of undefined (reading 'split')
at new SuperTokens (/var/task/node_modules/supertokens-node/lib/build/supertokens.js:370:24)
at SuperTokensWrapper.init (/var/task/node_modules/supertokens-node/lib/build/supertokens.js:408:36)
at 2290 (/var/task/.next/server/pages/api/auth/[[...path]].js:97:37)
at __webpack_require__ (/var/task/.next/server/webpack-api-runtime.js:25:42)
at __webpack_exec__ (/var/task/.next/server/pages/api/auth/[[...path]].js:145:39)
at /var/task/.next/server/pages/api/auth/[[...path]].js:146:70
at __webpack_require__.X (/var/task/.next/server/webpack-api-runtime.js:108:21)
at /var/task/.next/server/pages/api/auth/[[...path]].js:146:47
at Object.<anonymous> (/var/task/.next/server/pages/api/auth/[[...path]].js:149:3)
at Module._compile (node:internal/modules/cjs/loader:1256:14)
TypeError: Cannot read properties of undefined (reading 'split')
at new SuperTokens (/var/task/node_modules/supertokens-node/lib/build/supertokens.js:370:24)
at SuperTokensWrapper.init (/var/task/node_modules/supertokens-node/lib/build/supertokens.js:408:36)
at 2290 (/var/task/.next/server/pages/api/auth/[[...path]].js:97:37)
at __webpack_require__ (/var/task/.next/server/webpack-api-runtime.js:25:42)
at __webpack_exec__ (/var/task/.next/server/pages/api/auth/[[...path]].js:145:39)
at /var/task/.next/server/pages/api/auth/[[...path]].js:146:70
at __webpack_require__.X (/var/task/.next/server/webpack-api-runtime.js:108:21)
at /var/task/.next/server/pages/api/auth/[[...path]].js:146:47
at Object.<anonymous> (/var/task/.next/server/pages/api/auth/[[...path]].js:149:3)
at Module._compile (node:internal/modules/cjs/loader:1256:14)
RequestId: e3d16d2c-5438-4b9e-be86-d5fb8d42d225 Error: Runtime exited with error: exit status 1
Runtime.ExitError
rp_st
08/10/2023, 5:23 AMrp_st
08/10/2023, 5:23 AMyujonglee
08/10/2023, 6:14 AMcurl 'https://ringup.me/api/auth/session/refresh' \
-X 'POST' \
-H 'Accept: */*' \
-H 'Sec-Fetch-Site: same-origin' \
-H 'Accept-Language: en-US,en;q=0.9' \
-H 'Accept-Encoding: gzip, deflate, br' \
-H 'Sec-Fetch-Mode: cors' \
-H 'Host: ringup.me' \
-H 'Origin: https://ringup.me' \
-H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.4 Safari/605.1.15' \
-H 'Referer: https://ringup.me/auth' \
-H 'Content-Length: 0' \
-H 'Connection: keep-alive' \
-H 'Sec-Fetch-Dest: empty' \
-H 'st-auth-mode: cookie' \
-H 'fdi-version: 1.16,1.17' \
-H 'rid: session'
curl 'https://ringup.me/api/auth/signinup/code' \
-X 'POST' \
-H 'Content-Type: application/json' \
-H 'Accept: */*' \
-H 'Sec-Fetch-Site: same-origin' \
-H 'Accept-Language: en-US,en;q=0.9' \
-H 'Accept-Encoding: gzip, deflate, br' \
-H 'Sec-Fetch-Mode: cors' \
-H 'Host: ringup.me' \
-H 'Origin: https://ringup.me' \
-H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.4 Safari/605.1.15' \
-H 'Referer: https://ringup.me/auth' \
-H 'Content-Length: 29' \
-H 'Connection: keep-alive' \
-H 'Sec-Fetch-Dest: empty' \
-H 'st-auth-mode: cookie' \
-H 'fdi-version: 1.17' \
-H 'rid: passwordless' \
--data-binary '{"phoneNumber":<MY_NUMBER>}'
rp_st
08/10/2023, 6:15 AM--data-binary
rp_st
08/10/2023, 6:15 AMyujonglee
08/10/2023, 6:55 AM/auth
)
Below is when I hit continue
in UI.
curl
'https://ringup.me/api/auth/signinup/code' \
-X 'POST' \
-H 'Content-Type: application/json' \
-H 'Accept: */*' \
-H 'Sec-Fetch-Site: same-origin' \
-H 'Accept-Language: en-US,en;q=0.9' \
-H 'Accept-Encoding: gzip, deflate, br' \
-H 'Sec-Fetch-Mode: cors' \
-H 'Host: ringup.me' \
-H 'Origin: https://ringup.me' \
-H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.4 Safari/605.1.15' \
-H 'Referer: https://ringup.me/auth' \
-H 'Content-Length: 29' \
-H 'Connection: keep-alive' \
-H 'Sec-Fetch-Dest: empty' \
-H 'st-auth-mode: cookie' \
-H 'fdi-version: 1.17' \
-H 'rid: passwordless' \
--data-binary '{"phoneNumber":<MY_NUMBER>}'
yujonglee
08/10/2023, 6:55 AMrp_st
08/10/2023, 6:56 AMyujonglee
08/10/2023, 9:31 AMts
import PasswordlessNode from "supertokens-node/recipe/passwordless"
import SessionNode from "supertokens-node/recipe/session"
import { TwilioService } from "supertokens-node/recipe/passwordless/smsdelivery";
import { TypeInput } from "supertokens-node/types";
import { appInfo } from "./appInfo"
export const backendConfig = (): TypeInput => {
return {
framework: "express",
// supertokens: process.env.MY_ENV === "DEV"
// ? { connectionURI: "https://try.supertokens.io" }
// : {
// connectionURI: process.env.SUPERTOKENS_CONNECTION_URI!,
// apiKey: process.env.SUPERTOKENS_API_KEY!,
// },
supertokens: { connectionURI: "https://try.supertokens.io" },
appInfo,
recipeList: [
PasswordlessNode.init({
flowType: "USER_INPUT_CODE",
contactMethod: "PHONE",
smsDelivery: process.env.MY_ENV === "DEV"
? undefined
: {
service: new TwilioService({
twilioSettings: {
accountSid: process.env.TWILIO_ACCOUNT_SID!,
authToken: process.env.TWILIO_AUTH_TOKEN!,
from: process.env.TWILIO_PHONE_NUMBER!,
},
}),
},
override: {
functions: (oI: any) => {
return {
...oI,
signUp: async function (input: any) {
// First we call the original implementation of signUpPOST.
const response = await oI.signUp(input);
// Post sign up response, we check if it was successful
if (response.status === "OK") {
const { id, email } = response.user;
// TODO: post sign up logic
}
return response;
}
}
}
}
}),
SessionNode.init(),
],
isInServerlessEnv: true,
}
}
rp_st
08/10/2023, 9:34 AMrp_st
08/10/2023, 9:36 AM