File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed
packages/open-next/src/core Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " @opennextjs/aws " : patch
3+ ---
4+
5+ fix: fix basePath support for API routes
Original file line number Diff line number Diff line change @@ -34,6 +34,11 @@ const optionalBasepathPrefixRegex = !!RoutesManifest.basePath
3434 ? `^${ RoutesManifest . basePath } /?`
3535 : "^/" ;
3636
37+ // Add the basePath prefix to the api routes
38+ const apiPrefix = ! ! RoutesManifest . basePath
39+ ? `${ RoutesManifest . basePath } /api`
40+ : "/api" ;
41+
3742const staticRegexp = RoutesManifest . routes . static . map (
3843 ( route ) =>
3944 new RegExp (
@@ -145,8 +150,8 @@ export default async function routingHandler(
145150 // /api even if it's a page route doesn't get generated in the manifest
146151 // Ideally we would need to properly check api routes here
147152 const isApiRoute =
148- internalEvent . rawPath === "/api" ||
149- internalEvent . rawPath . startsWith ( "/api/" ) ;
153+ internalEvent . rawPath === apiPrefix ||
154+ internalEvent . rawPath . startsWith ( ` ${ apiPrefix } /` ) ;
150155
151156 const isNextImageRoute = internalEvent . rawPath . startsWith ( "/_next/image" ) ;
152157
You can’t perform that action at this time.
0 commit comments