-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
Describe the bug
I'm using a code-server cloud environment to develop a SvelteKit project. In order to access the dev server, a proxy is provided that uses a subpath to proxy the dev server port (see docs. This leads me to need a base path to be set for the dev server.
If I set kit.paths.base as stated in the documentation, the first page load works correctly but the import statements are relative to the root which returns a 404, correctly, because those files are not available without the proxy. If I run build and preview everything works as expected since the base path is built into the compiled project.
Expected behavior
All paths in the dev server reference the base path instead of being relative to the root domain.
Reproduction
- Create a new SvelteKit project
- Set
kit.paths.baseto a non-root path - Run the dev server
Expected result
All import statements look for paths with the base path or relative to the base path
Actual result
Module import statements are relative to the root
Logs
GEThttp://domain.tld/.svelte-kit/dev/runtime/internal/start.js
[HTTP/1.1 404 Not Found 8ms]
Loading module from “http://domain.tld/.svelte-kit/dev/runtime/internal/start.js” was blocked because of a disallowed MIME type (“application/json”). 3000
Loading failed for the module with source “http://domain.tld/.svelte-kit/dev/runtime/internal/start.js”. 3000:13:1
GEThttp://domain.tld/favicon.png
[HTTP/1.1 404 Not Found 6ms]System Info
System:
OS: Linux 5.10 Ubuntu 20.04.3 LTS (Focal Fossa)
CPU: (12) x64 Intel(R) Core(TM) i5-10400 CPU @ 2.90GHz
Memory: 283.55 MB / 15.32 GB
Container: Yes
Shell: 5.0.17 - /bin/bash
Binaries:
Node: 14.18.2 - /usr/bin/node
Yarn: 1.22.15 - /usr/bin/yarn
npm: 6.14.15 - /usr/bin/npm
npmPackages:
@sveltejs/kit: ^1.0.0-next.201 => 1.0.0-next.201
svelte: ^3.42.6 => 3.44.2Severity
annoyance
Additional Information
I've been using the absproxy method with code-server. This passes the full path with the /absproxy/3000 portion intact. This seems like the correct approach for usage with kit.paths.base. I think this method would work fine if the dev server accounted for it when building the pages.
However, there is also the proxy method. The proxy method strips of the proxy subpath before passing the request to the dev server. Thus, on the dev server, all the paths are relative to root. If there was a way to specify a subpath only for use on the client side, this may also be a reasonable solution.
I've made some inline edits to the @sveltejs/kit package in node_modules and was able to get the proxy method working. It would require a config field to set it, of course. Obviously, not everyone is working in a cloud server 😄

