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

Error: [vike][Wrong Usage] vite.config.js#base should start with /, http://, or https:// (it's ./ instead) #1223

Closed
samuelstroschein opened this issue Oct 31, 2023 · 3 comments
Labels
enhancement ✨ New feature or request

Comments

@samuelstroschein
Copy link
Contributor

samuelstroschein commented Oct 31, 2023

Description

Vike throws an error on a base config of ./ that Vite explicitly allows:

CleanShot 2023-10-30 at 23 23 19@2x

https://vitejs.dev/config/shared-options.html#base

Why is ./ needed?

Enable embedded deployments via reverse proxies. Without a relative base path, clients potentially resolve wrong static assets.

Example

reverse proxy: /editor -> localhost:3001/
reverse proxy: /app -> localhost:3002/ 

a user requesting `/editor` without a relative base path of HTML that contains an asset like `/image.png` will resolve to `<reverse-proxy>/image.png` instead of `/editor/image.png`. 

Reproduction

https://stackblitz.com/edit/vitejs-vite-eowwvq?file=vike-app%2Fvite.config.js

  1. add base './' to the vite config
  2. run npm run dev
// vite.config.ts

export default {
  plugins: [react(), vike()],
+  base: './',
};

cc @NiklasBuchfink

@brillout brillout added enhancement ✨ New feature or request and removed bug 💥 labels Oct 31, 2023
@brillout
Copy link
Member

I'm guessing that /editor and /app are two distinct Vike apps. AFAICT an absolute base path works just fine in that situation: set base: '/editor' for the editor, and base: '/app' for the app.

Closing, but let's continue the discussion and I'll potentially re-open.

@brillout brillout closed this as not planned Won't fix, can't repro, duplicate, stale Oct 31, 2023
@lourot
Copy link
Contributor

lourot commented Dec 16, 2023

FYI this is a bit of a deal breaker for @bloodchen. Here is the use case: they want to build a full SSG website, zip /dist/client and tell their client to unzip that anywhere in their statically served filesystem, say /var/www/html/anywhere/hello/ and expect all the links to work because they set base: './' before building.

As I got approached with "just remove that assertion", I did an experiment. I took a trivial SSG example, set base: './' and tried to get the build passing by just removing assertions. I ended up having to remove 20+ assertions and as expected, links were broken in the output.

If we want to support this, say for SSG only, this is going to require a significant effort.

@brillout
Copy link
Member

@bloodchen See disucssion at #606.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement ✨ New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants