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

Support relative path prefixes (base in vite.config.js) #866

Closed
tommed opened this issue Oct 10, 2023 · 2 comments
Closed

Support relative path prefixes (base in vite.config.js) #866

tommed opened this issue Oct 10, 2023 · 2 comments

Comments

@tommed
Copy link

tommed commented Oct 10, 2023

I am trying to deploy a UI which is accessed from a relative path rather than root directory:

https://MY_DOMAIN.TLD/london/fileshare

To achieve this, I have a relative path set in my VueJS vite.config.js file:

export default defineConfig({
  base: '/london/fileshare',
  // ...
}

However, when it comes to serving the web site, all requests (including static file requests like https://MY_DOMAIN/london/fileshare/assets/index-c9fdd385.css return index.html because it's clearly looking for a static file at london/fileshare/assets/index-c9fdd385.css rather than assets/index-c9fdd385.css. This is because there is no way to tell the web server this is being accessed from a local path.

If I omit the base value from vite.config.js, it renders the assets to /assets/index-c9fdd385.css and the root directory is obviously outside of the application so will fail too.

Clearly the web server just needs to be aware of the relative path prefix?

Environment Versions

  1. OS Type macOS and ubuntu/node docker images - it's a conceptual problem which exists regardless of OS
  2. Node version: $ node --version :latest docker image

Steps to reproduce

  1. Set relative base path in vite.config.js
  2. npm run build host in a http-server process
  3. Make a request and watch the .css and .js requests fail to connect to the static files

Expected result

Be able to inform the http-server about the relative path, and for it not to be included when locating static content.

Actual result

http-server is using the relative path prefix when looking for local static file content, it should instead be trimming this from the request path first.

@zbynek
Copy link
Contributor

zbynek commented Oct 10, 2023

See #294, #139, #595, ...

Also: AFAIK there are just 2 people with maintainer access of this project and neither of them has shown any interest in the last year, so you might be better off switching to serve, which supports rewrites: https://github.com/vercel/serve-handler#rewrites-array

@tommed
Copy link
Author

tommed commented Oct 11, 2023

Yikes, such as shame.
Let's hope our new AI overlords don't get bored so easily 🤣
I read somewhere that 45% of code written on GitHub is now AI generated?!

@tommed tommed closed this as completed Oct 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants