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.base to 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
Example


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.2
Severity
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 😄
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.baseas stated in the documentation, the first page load works correctly but theimportstatements are relative to the root which returns a 404, correctly, because those files are not available without the proxy. If I runbuildandprevieweverything 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
kit.paths.baseto a non-root pathExpected result
All
importstatements look for paths with the base path or relative to the base pathActual result
Module
importstatements are relative to the rootExample


Logs
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
absproxymethod with code-server. This passes the full path with the/absproxy/3000portion intact. This seems like the correct approach for usage withkit.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
proxymethod. Theproxymethod 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/kitpackage innode_modulesand was able to get theproxymethod working. It would require a config field to set it, of course. Obviously, not everyone is working in a cloud server 😄