question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`base` option does not support external URLs with the development server

See original GitHub issue

⚠️ IMPORTANT ⚠️ Please check the following list before proceeding. If you ignore this issue template, your issue will be directly closed.

  • Read the docs.
  • Use Vite >=2.0. (1.x is no longer supported)
  • If the issue is related to 1.x -> 2.0 upgrade, read the Migration Guide first.

Describe the bug

The base option currently does not support the ability to specify external URLs when serving content through the development server. This greatly limits the incorporation of Vite into other backends (Laravel, etc.) as static assets can no longer be served since the assets are served on a different port than the web server. I explored this specific problem in more depth in a separate issue by attempting to integrate Vite into a Laravel project.

As a solution suggestion, I believe that this issue would be solved best by implementing an environment variable to specify a URL base for content served specifically through the dev server. This would resolve these issues with backend compatibility and allow for the most flexability in users’ dev environments.

Reproduction

I’m not sure how worthwhile a reproduction guide is for this issue, but this should give you something to compare against.

  1. Create a vue-ts project using the @vitejs/app init script
npm init @vitejs/app
    # Project name: vite-static-assets
    # Select a template: vue-ts
cd vite-static-assets
npm install
  1. Set base property in vite.config.ts:
export default defineConfig({
  base: "http://localhost:3000/",
  server: {
    port: 3000 // Use the same port for dev and serve
  },
  // ...
})
  1. Compare the URL of the Vue logo in the inspector window between content served via npm run dev and npm run build && npm run serve. The src attribute of the <img> tag will only contain the base of http://localhost:3000/ on production builds.

System Info

  • vite version: 2.0.1
  • Operating System: Ubuntu 20.10
  • Node version: 14.15.4
  • Package manager (npm/yarn/pnpm) and version: npm

Logs (Optional if provided reproduction)

N/A

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

11reactions
ugruppcommented, May 10, 2021

Don’t want to be pushy but could we at least reopen this issue? I’m trying to get Vite working with Craft, too, and this is the biggest blocker right now.

9reactions
khalwatcommented, May 10, 2021

Agree, would love to see this re-opened, I referenced it here: https://nystudio107.com/blog/using-vite-js-next-generation-frontend-tooling-with-craft-cms#vite-processed-assets

…and it is still an issue, at least imo.

Read more comments on GitHub >

github_iconTop Results From Across the Web

django HttpResponseRedirect broken when accessing ...
This works flawlessly on django development server but is broken in my production environment. Namely, it does not redirect to external url ......
Read more >
How to handle environment-specific settings in your ...
Option 1: Host the API with the app​​ Simple. Just host the app and API from the same webserver, so relative URLs work...
Read more >
Configure the create-react-app public URL post-build with ...
For a project, I had the requirement of making the public URL of the application configurable via an environment variable that can be...
Read more >
API Server and Base Path - Swagger
WebSocket schemes ws:// and wss:// from OpenAPI 2.0 are also supported in ... If the servers array is not provided or is empty,...
Read more >
DevServer - webpack
This option allows specifying URL to web socket server (useful when you're proxying dev server and client script does not always know where...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found