File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed
packages/start/src/server Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " @solidjs/start " : patch
3+ ---
4+
5+ Handle base url in api routes
Original file line number Diff line number Diff line change @@ -32,10 +32,9 @@ export function createBaseHandler(
3232 handler : decorateHandler ( async ( e : H3Event ) => {
3333 const event = getRequestEvent ( ) ! ;
3434 const url = new URL ( event . request . url ) ;
35- const pathname = url . pathname ;
35+ const pathname = stripBaseUrl ( url . pathname ) ;
3636
37- const serverFunctionTest = join ( import . meta. env . BASE_URL , SERVER_FN_BASE ) ;
38- if ( pathname . startsWith ( serverFunctionTest ) ) {
37+ if ( pathname . startsWith ( SERVER_FN_BASE ) ) {
3938 const serverFnResponse = await handleServerFunction ( e ) ;
4039
4140 if ( serverFnResponse instanceof Response )
@@ -265,3 +264,8 @@ function produceResponseWithEventHeaders(res: Response) {
265264
266265 return ret
267266}
267+
268+ function stripBaseUrl ( path : string ) {
269+ if ( import . meta. env . BASE_URL === "/" || import . meta. env . BASE_URL === "" ) return path ;
270+ return path . slice ( import . meta. env . BASE_URL . length ) ;
271+ }
You can’t perform that action at this time.
0 commit comments