Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,10 @@ export async function proxy(request: NextRequest) {
const skipPreviewAuth = process.env.DISABLE_PREVIEW_AUTH === 'true'
&& pathname.startsWith('/ycode/preview');

// Protect API and preview routes with auth
if (!skipPreviewAuth && (pathname.startsWith('/ycode/api') || pathname.startsWith('/ycode/preview'))) {
// Protect API and preview routes with auth. `/api/templates` lives outside the
// `/ycode` tree (public site route group) but exposes destructive builder-only
// operations (apply/export), so it must be gated here too.
if (!skipPreviewAuth && (pathname.startsWith('/ycode/api') || pathname.startsWith('/ycode/preview') || pathname.startsWith('/api/templates'))) {
const authResponse = await verifyApiAuth(request);
if (authResponse) {
if (authResponse.status === 401) {
Expand Down