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.

Relative publicPath with history router mode adds prefix '/' to base href

See original GitHub issue

Describe the bug When setting publicPath to ‘./’ and using history router mode, the base href inserted into the html contains an extra prefix /.

This means that I cannot deploy my application to a dynamic environment where it will be hosted at both www.example.com and www.someotherexample.com/apath.

To Reproduce Steps to reproduce the behavior:

  1. Configure vueRouterMode to 'history' in quasar.conf.js
  2. Configure publicPath to './', or '.' or '' in quasar.conf.js
  3. Run project

Expected behavior I expect the <base href to contain a relative path.

Screenshots image

Platform (please complete the following information): Quasar Version: @quasar/app Version: Quasar mode: [X] SPA [ ] SSR [ ] PWA [ ] Electron [ ] Cordova [ ] Capacitor [ ] BEX Tested on: [X] SPA [ ] SSR [ ] PWA [ ] Electron [ ] Cordova [ ] Capacitor [ ] BEX OS: Mac Node: 10.23 NPM: 6.14.11 Yarn: Not installed Browsers: Firefox, Chrome iOS: Android: Electron:

❯ quasar info

Operating System - Darwin(19.6.0) - darwin/x64
NodeJs - 10.23.0

Global packages
  NPM - 6.14.11
  yarn - Not installed
  @quasar/cli - 1.1.3
  @quasar/icongenie - Not installed
  cordova - Not installed

Important local packages
  quasar - 1.15.4 -- Build high-performance VueJS user interfaces (SPA, PWA, SSR, Mobile and Desktop) in record time
  @quasar/app - 2.1.15 -- Quasar Framework local CLI
  @quasar/extras - 1.9.17 -- Quasar Framework fonts, icons and animations
  eslint-plugin-quasar - Not installed
  vue - 2.6.12 -- Reactive, component-oriented view layer for modern web interfaces.
  vue-router - 3.2.0 -- Official router for Vue.js 2
  vuex - 3.6.0 -- state management for Vue.js
  electron - Not installed
  electron-packager - Not installed
  electron-builder - Not installed
  @babel/core - 7.12.17 -- Babel compiler core.
  webpack - 4.44.2 -- Packs CommonJs/AMD modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.
  webpack-dev-server - 3.11.0 -- Serves a webpack app. Updates the browser on changes.
  workbox-webpack-plugin - Not installed
  register-service-worker - 1.7.1 -- Script for registering service worker, with hooks
  typescript - 3.9.5 -- TypeScript is a language for application scale JavaScript development
  @capacitor/core - Not installed
  @capacitor/cli - Not installed
  @capacitor/android - Not installed
  @capacitor/ios - Not installed

Additional context Issue #4451 describes the same issue but with full urls. The fix in commit f70bf797301002fc9c0f0403a44c574dc2559062 only seems to respect http paths. It is obvious from looking at the code that any path not starting with a / will get a leading /. Even passing in null or ‘empty string’, ends up with a base href of /.

Perhaps this is by design and this scenario is not supported?

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:1
  • Comments:9

github_iconTop GitHub Comments

6reactions
philnagelcommented, May 16, 2022

Adding the following to build in my quasar.config.js file resolved this issue for me:

    build: {
      extendViteConf(viteConf, { isServer, isClient }) {
        viteConf.base = "";
      },
      ...
    }

This is if you are using vite.

1reaction
mvalerocommented, Mar 2, 2022

@eyedean I don’t completely agree on that, the architectural context was provided to depict the use case where we are facing that issue. But regardless from the architectural context there is a mismatch in the behavior from vuejs cli and quasar cli where quasar seems to be explicitly avoiding relative public paths.

See https://cli.vuejs.org/config/#publicpath where its stated publicPath can also be relative. After testing both vanilla vue cli with publicPath: '.' the generated paths on vue cli are href="css/app.xxx.css" and on quasar cli href="/./css/app.xxx.css"

So my main question regarding quasar’s behavior would be, is there a reason why a relative publicPath is being explicitly avoided and therefore behaving differently that vanilla VueJS cli?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Build SPA app with relative base path - Quasar forum
I'm using quasar CLI 2.2.1. I'm trying to figure out whether it's possible to build a SPA app using Vue router, so that...
Read more >
Bountysource
Relative publicPath with history router mode adds prefix '/' to base href.
Read more >
How to load JavaScript chunks from webpage relative to origin ...
I have a React client built with webpack. It adds every file to a URL/version/ folder. However, once the HTML page is loaded, ......
Read more >
Different History modes - Vue Router
It uses a hash character ( # ) before the actual URL that is internally passed. Because this section of the URL is...
Read more >
Configuring quasar.config.js
Or you can configure the dev server to run on port 8000 for SPA mode, ... vueRouterBase, String, Force vue router base with...
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