fix: use 303 redirect for checkout POST to prevent header errors

- Changed NextResponse.redirect() to Response with 303 status
- Added .gitignore file
This commit is contained in:
Jeff Emmett 2026-01-18 18:07:11 +01:00
parent f19bf65e7b
commit 25d77b6d7f
4 changed files with 800 additions and 990 deletions

40
.gitignore vendored Normal file
View File

@ -0,0 +1,40 @@
# Dependencies
node_modules/
.pnpm-store/
# Next.js
.next/
out/
# Build
dist/
build/
# Environment
.env
.env.local
.env.development.local
.env.test.local
.env.production.local
# IDE
.idea/
.vscode/
*.swp
*.swo
# OS
.DS_Store
Thumbs.db
# Logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Testing
coverage/
# Misc
*.tsbuildinfo

View File

@ -86,7 +86,11 @@ export async function POST(request: NextRequest) {
}, },
}) })
return NextResponse.redirect(session.url!) // Use 303 redirect for POST requests (tells browser to follow with GET)
return new Response(null, {
status: 303,
headers: { Location: session.url! },
})
} catch (err) { } catch (err) {
console.error("Error creating checkout session:", err) console.error("Error creating checkout session:", err)
return NextResponse.json({ error: "Error creating checkout session" }, { status: 500 }) return NextResponse.json({ error: "Error creating checkout session" }, { status: 500 })

View File

@ -46,7 +46,7 @@
"embla-carousel-react": "8.5.1", "embla-carousel-react": "8.5.1",
"input-otp": "1.4.1", "input-otp": "1.4.1",
"lucide-react": "^0.454.0", "lucide-react": "^0.454.0",
"next": "16.0.3", "next": "16.0.10",
"next-themes": "^0.4.6", "next-themes": "^0.4.6",
"react": "19.2.0", "react": "19.2.0",
"react-day-picker": "9.8.0", "react-day-picker": "9.8.0",

File diff suppressed because it is too large Load Diff