Skip to content

Commit

Permalink
fix: config loading for route handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasio committed Jul 3, 2024
1 parent b01a4ba commit 631dbdc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 6 additions & 1 deletion packages/next/src/config/withHeadstartWPConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,16 @@ export function withHeadstartWPConfig(
return false;
}

if (moduleRequest.includes('node_modules')) {
return false;
}

const matched =
/_app.(tsx|ts|js|mjs|jsx)$/.test(moduleRequest) ||
/middleware.(ts|js|mjs)$/.test(moduleRequest) ||
/pages\/api\/.*.(ts|js|mjs)/.test(moduleRequest) ||
/app\/.*layout.(tsx|ts|js|mjs|jsx)$/.test(moduleRequest);
/app\/.*layout.(tsx|ts|js|mjs|jsx)$/.test(moduleRequest) ||
/app\/.*.\/route.(ts|js|mjs)$/.test(moduleRequest);

return matched;
},
Expand Down
4 changes: 0 additions & 4 deletions projects/wp-nextjs-app/src/app/api/preview/route.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import { previewRouteHandler } from '@headstartwp/next/app';
import type { NextRequest } from 'next/server';
import { setHeadlessConfig } from '@headstartwp/core';
import config from '../../../../headstartwp.config';

setHeadlessConfig(config);

export async function GET(request: NextRequest) {
// @ts-expect-error
Expand Down

0 comments on commit 631dbdc

Please sign in to comment.