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.

dev server asking me to double up the set `base` url

See original GitHub issue

Describe the bug

If I run npm run dev (which runs vite) it uses port 3000 by default along with what I set for base in vite.config.js.

When I visit the URL provided I get the message:

The server is configured with a public base URL of /pages/XDS/living-docs/ - did you mean to visit /pages/XDS/living-docs/pages/XDS/living-docs instead?

It’s doubled up and I have no idea why (and that URL doesn’t work either, the new message triples up to /pages/XDS/living-docs/pages/XDS/living-docs/pages/XDS/living-docs).

  • If I set the port to 3001 it works correctly, I can view it at locahost:3001/pages/XDS/living-docs.
  • If I change the base path it works correctly (just removing the s at the end), I can view it at locahost:3000/pages/XDS/living-doc.
  • It builds for production just fine.

Does anyone see any reason for that? Is there some sort of cache outside of the project I can clear?

Reproduction

I feel the error is clear enough. If it is not let me know and I will try to remove personal information.

System Info

Output of npx envinfo --system --npmPackages vite,@vitejs/plugin-vue --binaries --browsers:

System:
  OS: macOS 11.2.3
  CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
  Memory: 1.81 GB / 16.00 GB
  Shell: 3.2.57 - /bin/bash
Binaries:
  Node: 12.18.4 - ~/.nvm/versions/node/v12.18.4/bin/node
  Yarn: 1.22.10 - ~/.nvm/versions/node/v12.18.4/bin/yarn
  npm: 7.5.4 - ~/.nvm/versions/node/v12.18.4/bin/npm
Browsers:
  Brave Browser: 89.1.22.71
  Chrome: 89.0.4389.114
  Chrome Canary: 91.0.4471.0
  Edge: 83.0.478.64
  Firefox: 87.0
  Firefox Developer Edition: 80.0
  Safari: 14.0.3
npmPackages:
  vite: ^2.1.5 => 2.1.5

Used package manager: Tried with both npm and yarn. Same outcome.

Logs

There is really no error message but here’s the output anyway:

> proto@0.0.0 dev /Users/bill/www/xds-living-doc
> vite --debug

  vite:config bundled config file loaded in 52ms +0ms
  vite:config using resolved config: {
  vite:config   esbuild: {
  vite:config     jsxFactory: 'h',
  vite:config     jsxFragment: 'Fragment',
  vite:config     jsxInject: "import { h, Fragment } from 'preact'"
  vite:config   },
  vite:config   base: '/pages/XDS/living-docs/',
  vite:config   plugins: [
  vite:config     'vite:pre-alias',
  vite:config     'alias',
  vite:config     'vite:dynamic-import-polyfill',
  vite:config     'vite:resolve',
  vite:config     'vite:html',
  vite:config     'vite:css',
  vite:config     'vite:esbuild',
  vite:config     'vite:json',
  vite:config     'vite:wasm',
  vite:config     'vite:worker',
  vite:config     'vite:asset',
  vite:config     'prefresh',
  vite:config     'vite:define',
  vite:config     'vite:css-post',
  vite:config     'vite:client-inject',
  vite:config     'vite:import-analysis'
  vite:config   ],
  vite:config   server: {},
  vite:config   configFile: '/Users/bill/www/xds-living-doc/vite.config.js',
  vite:config   inlineConfig: {
  vite:config     root: undefined,
  vite:config     base: undefined,
  vite:config     mode: undefined,
  vite:config     configFile: undefined,
  vite:config     logLevel: undefined,
  vite:config     clearScreen: undefined,
  vite:config     server: {}
  vite:config   },
  vite:config   root: '/Users/bill/www/xds-living-doc',
  vite:config   resolve: { dedupe: undefined, alias: [ [Object] ] },
  vite:config   publicDir: '/Users/bill/www/xds-living-doc/public',
  vite:config   command: 'serve',
  vite:config   mode: 'development',
  vite:config   isProduction: false,
  vite:config   optimizeCacheDir: '/Users/bill/www/xds-living-doc/node_modules/.vite',
  vite:config   build: {
  vite:config     target: [ 'es2019', 'edge18', 'firefox60', 'chrome61', 'safari11' ],
  vite:config     polyfillDynamicImport: true,
  vite:config     outDir: 'dist',
  vite:config     assetsDir: 'assets',
  vite:config     assetsInlineLimit: 4096,
  vite:config     cssCodeSplit: true,
  vite:config     sourcemap: false,
  vite:config     rollupOptions: {},
  vite:config     commonjsOptions: { include: [Array], extensions: [Array] },
  vite:config     minify: 'terser',
  vite:config     terserOptions: {},
  vite:config     cleanCssOptions: {},
  vite:config     write: true,
  vite:config     emptyOutDir: null,
  vite:config     manifest: false,
  vite:config     lib: false,
  vite:config     ssr: false,
  vite:config     ssrManifest: false,
  vite:config     brotliSize: true,
  vite:config     chunkSizeWarningLimit: 500
  vite:config   },
  vite:config   env: {
  vite:config     BASE_URL: '/pages/XDS/living-docs/',
  vite:config     MODE: 'development',
  vite:config     DEV: true,
  vite:config     PROD: false
  vite:config   },
  vite:config   assetsInclude: [Function: assetsInclude],
  vite:config   logger: {
  vite:config     hasWarned: false,
  vite:config     info: [Function: info],
  vite:config     warn: [Function: warn],
  vite:config     error: [Function: error],
  vite:config     clearScreen: [Function: clearScreen]
  vite:config   },
  vite:config   createResolver: [Function: createResolver]
  vite:config } +3ms
  vite:deps Hash is consistent. Skipping. Use --force to override. +0ms

  vite v2.1.5 dev server running at:

  > Local:    http://localhost:3000/pages/XDS/living-docs/
  > Network:  http://10.0.0.101:3000/pages/XDS/living-docs/
  > Network:  http://10.166.107.120:3000/pages/XDS/living-docs/

  ready in 170ms.

  vite:time 1ms   /pages/XDS/living-docs +0ms
  vite:resolve 2ms   /_next/webpack-hmr?page=/_error -> null +0ms
  vite:spa-fallback Not rewriting GET /_next/webpack-hmr?page=/_error because the client does not accept HTML. +0ms
  vite:time 6ms   /_next/webpack-hmr?page=/_error +2s
  vite:spa-fallback Not rewriting GET /_next/webpack-hmr?page=/_error because the client does not accept HTML. +7s
  vite:time 2ms   /_next/webpack-hmr?page=/_error +7s
  vite:spa-fallback Not rewriting GET /_next/webpack-hmr?page=/_error because the client does not accept HTML. +5s
  vite:time 1ms   /_next/webpack-hmr?page=/_error +5s


Before submitting the issue, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the docs.
  • Check that there isn’t already an issue that reports the same bug to avoid creating a duplicate.
  • Provide a description in this issue that describes the bug.
  • Make sure this is a Vite issue and not a framework-specific issue. For example, if it’s a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/vue-next instead.
  • Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
sodateacommented, Apr 9, 2021

I see. Though I’m not sure if it’s related to Vite, it can be fixed on your browser-side by invalidating all the caches on this domain.

Somehow it’s constantly redirecting /xds-living-docs/ (which typically means /xds-living-docs/index.html) to /xds-living-docs (which typically means /xds-living-docs.html). May be caused by an HTTP 301 response code from a misconfigured static server that you previously accessed, and the browser cached that response.

0reactions
crswllcommented, Apr 16, 2021

For anyone that may come across this I think the issue is due Next setting up redirects (they both use 3000 by default).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Set the baseUrl for the dev-server · Issue #546 - GitHub
I just spent many hours trying to work out how to mount the dev server at a child path in the URL. ......
Read more >
How to tell webpack dev server to serve index.html for any route
I found the easiest solution to include a small config: devServer: { port: 3000, historyApiFallback: { index: 'index.html' } }. I found this...
Read more >
Secure Server-to-Server Communication with Spring Boot and ...
My scenario is for server to server communication. I have set up a application for the consumer in the okta developer account. I...
Read more >
How to replace all hard coded links after a base URL change
If a link was created as a relative link (for example, by using Edit > Insert > Link, then from "Recently Viewed" or...
Read more >
App BaseUrl with port # - FAQs - monday Community Forum
Hi, I need to use a URL for the App BaseUrl that includes a port # (ex: https://www.example.com:3000). It doesn't seem to be...
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