Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev server files are not loaded with base path #6071

Closed
7 tasks done
andycarlberg opened this issue Dec 10, 2021 · 2 comments
Closed
7 tasks done

Dev server files are not loaded with base path #6071

andycarlberg opened this issue Dec 10, 2021 · 2 comments

Comments

@andycarlberg
Copy link

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 a base path as stated in the documentation, the first page load works correctly but the import statements on the rendered page are relative to the root. These return a 404, correctly, because those files are not available without the proxy.

Related to sveltejs/kit#2958

Expected behavior
All paths in the dev server reference the base path instead of being relative to the root domain. If necessary, the dev server strips the base path to find the dev server files.

Reproduction

  1. Create a new Vite project
  2. Set base path to a non-root path
  3. Run the dev server

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: 560.98 MB / 15.32 GB
    Container: Yes
    Shell: Unknown - /bin/false
  Binaries:
    Node: 14.18.2 - /usr/bin/node
    Yarn: 1.22.15 - /usr/bin/yarn
    npm: 6.14.15 - /usr/bin/npm
  npmPackages:
    vite: ^2.6.14 => 2.6.14

Used Package Manager

npm

Logs

No response

Validations

@Bastian
Copy link

Bastian commented Dec 14, 2021

Since I ran into the same issue with Svelte-Kit, I don't quite understand why you believe that this is a Vite problem.
With the following vite.config.ts in a Vanilla-TS Vite (v2.7.2) project, everything works like I would expect it:

import { defineConfig } from 'vite';

// https://vitejs.dev/config/
export default defineConfig({
    base: '/base-path/',
});

image

Am I missing something?

@andycarlberg
Copy link
Author

No, agreed, I must have been doing something wrong before. This doesn't seem to be a Vite issue. I'm fairly new to Vite and I must have configured something incorrectly before. I am seeing the behavior work correctly in a vanilla Vite project.

@github-actions github-actions bot locked and limited conversation to collaborators Dec 29, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants