solid-start
solid-start copied to clipboard
[Bug?]: Configuring `server.baseURL` will make the `api` route inaccessible
Duplicates
- [x] I have searched the existing issues
Latest version
- [x] I have tested the latest version
Current behavior 😯
Expected behavior 🤔
Steps to reproduce 🕹
Steps:
- Configuring
app.config.ts
defineConfig({
server: {
baseURL:"/the_project",
},
});
- Create a file
src/routes/api/info.ts
import type { APIHandler } from '@solidjs/start/server';
export const POST: APIHandler = async (event) => {
return {
name: 'John POST',
};
};
- fetch api
fetch("/the_project/api/info", {
"method": "POST",
});
Context 🔦
After debugging, I think the bug is here
https://github.com/solidjs/solid-start/blob/28e3fc5030b4a4eb06c7e3b17bd17569f4873b14/packages/start/src/server/handler.ts#L47
new URL(event.request.url).pathname = /the_project/api/info ,but in router is /api/info
https://github.com/solidjs/solid-start/blob/28e3fc5030b4a4eb06c7e3b17bd17569f4873b14/packages/start/src/router/routes.ts#L61
After modification, it can run normally
const match = matchAPIRoute(event.nativeEvent.path, event.request.method);
Your environment 🌎