solid-start: [Bug?]: Router "base" property is flaky

UPDATE (moving focus from base prop in vite.config to base prop on Router): For repro instructions, see https://github.com/solidjs/solid-start/issues/1158#issuecomment-1867734373

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Current behavior 😯

Currently the /_build is the default base path:

https://github.com/solidjs/solid-start/blob/cfe17fa2da37726ef59be347efbef4d8274b74aa/packages/start/config/index.js#L156

Expected behavior πŸ€”

I expected either / or β€˜β€™ to be the default base path unless set otherwise. If i set it to these values, my routes return nothing.

Steps to reproduce πŸ•Ή

  • npm create solid.
  • choose bare template

set the vite config to:

export default defineConfig({
  base: "/test/"
});

Context πŸ”¦

I’m making a SSG docs site, on a subpath like this example.com/subpath/routes and thus need to set the base to /subpath/

this is to some extend a remake of the now obsolete

Your environment 🌎

@solidjs/start 0.4
@solidjs/router 0.10
macos - arm64
chrome 120

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 17 (16 by maintainers)

Commits related to this issue

Most upvoted comments

I tried this again and it looks like it works:

{
  "name": "test-base-url",
  "type": "module",
  "scripts": {
    "dev": "vinxi dev",
    "build": "vinxi build",
    "start": "vinxi start"
  },
  "dependencies": {
    "@solidjs/meta": "^0.29.2",
    "@solidjs/router": "^0.10.5",
    "@solidjs/start": "^0.4.2",
    "solid-js": "^1.8.7",
    "vinxi": "0.0.55"
  },
}
import { defineConfig } from "@solidjs/start/config";

export default defineConfig({
  start: {
    server: {
      baseURL: "/base",
    },
  },
});
// @refresh reload
import { MetaProvider, Title } from "@solidjs/meta";
import { A, Router } from "@solidjs/router";
import { FileRoutes } from "@solidjs/start";
import { Suspense } from "solid-js";
import "./app.css";

export default function App() {
  return (
    <Router
      base={import.meta.env.SERVER_BASE_URL}
      root={(props) => (
        <MetaProvider>
          <Title>SolidStart - Basic</Title>
          <A href="/">Index</A>
          <A href="/about">About</A>
          <Suspense>{props.children}</Suspense>
        </MetaProvider>
      )}
    >
      <FileRoutes />
    </Router>
  );
}

also @ryansolid looks like lower case a links are not picking up the base from the router, but uppsercase A links are.

Could you try vinxi@0.0.55. This should be fixed in that. Passing server.baseURL should give you the correct url in import.meta.env.SERVER_BASE_URL. And your entire app will be served at server.baseURL.

I think some issues with the base being used properly across the system still need things fixed in solid-start and vinxi, so better to keep this open.