Open Thinkscape opened 1 month ago
Poor-man's workaround, which doesn't work well with server actions but might be useful when used with other fetch() wrappers and POST
-ing into api routes behind auth middleware.
// /src/app/api/auth/[kindeAuth]/route.ts
import { handleAuth } from "@kinde-oss/kinde-auth-nextjs/server";
import { NextResponse } from "next/server";
export const GET = handleAuth();
export const POST = () =>
NextResponse.json(
{
error: {
name: "unauthorized",
message: "Logged out",
status: 401,
},
},
{
status: 401,
},
);
Prerequisites
Describe the issue
Steps
POST
request to one of the api routes (or invoked a server action)POST /api/auth/login
Expected
The handler redirects to login, or better yet, allows to handle it otherwise to inform the front-end that session has expired and user needs to be logged in again.
Actual
🔴
/api/auth/login?post_login_redirect_url=... 405 Method Not Allowed
Library URL
https://github.com/kinde-oss/kinde-auth-react
Library version
2.2.10
Operating system(s)
macOS
Operating system version(s)
23E224
Further environment details
No response
Reproducible test case URL
No response
Additional information
No response