Skip to content

[Bug?]: Configuring server.baseURL will make the api route inaccessible #1857

@thinke5

Description

@thinke5

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Current behavior 😯

Image

Expected behavior 🤔

Image

Steps to reproduce 🕹

Steps:

  1. Configuring app.config.ts
defineConfig({
  server: {
    baseURL:"/the_project",
  },
});
  1. 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',
  };
};
  1. fetch api
fetch("/the_project/api/info", {
  "method": "POST",
});

Context 🔦

After debugging, I think the bug is here

const match = matchAPIRoute(new URL(event.request.url).pathname, event.request.method);

new URL(event.request.url).pathname = /the_project/api/info ,but in router is /api/info

const match = router.lookup(path);

After modification, it can run normally

const match = matchAPIRoute(event.nativeEvent.path, event.request.method);

Your environment 🌎

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions