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

URIError: Failed to decode param '/%3C%=%20webpackConfig.output.publicPath%20%%3Efavicon.ico' #1451

Closed
marco-carvalho opened this issue Jun 3, 2018 · 21 comments

Comments

@marco-carvalho
Copy link

Version

3.0.0-beta.15

Reproduction link

https://github.com/marco-carvalho/music

Steps to reproduce

git clone https://github.com/marco-carvalho/music
npm i
npm run serve

What is expected?

App running at:

What is actually happening?

App running at:

URIError: Failed to decode param '/%3C%=%20webpackConfig.output.publicPath%20%%3Efavicon.ico'
at decodeURIComponent ()
at decode_param (/media/marco/Backup/Git/music/node_modules/express/lib/router/layer.js:172:12)
at Layer.match (/media/marco/Backup/Git/music/node_modules/express/lib/router/layer.js:123:27)
at matchLayer (/media/marco/Backup/Git/music/node_modules/express/lib/router/index.js:574:18)
at next (/media/marco/Backup/Git/music/node_modules/express/lib/router/index.js:220:15)
at expressInit (/media/marco/Backup/Git/music/node_modules/express/lib/middleware/init.js:40:5)
at Layer.handle [as handle_request] (/media/marco/Backup/Git/music/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/media/marco/Backup/Git/music/node_modules/express/lib/router/index.js:317:13)
at /media/marco/Backup/Git/music/node_modules/express/lib/router/index.js:284:7
at Function.process_params (/media/marco/Backup/Git/music/node_modules/express/lib/router/index.js:335:12)
at next (/media/marco/Backup/Git/music/node_modules/express/lib/router/index.js:275:10)
at query (/media/marco/Backup/Git/music/node_modules/express/lib/middleware/query.js:45:5)
at Layer.handle [as handle_request] (/media/marco/Backup/Git/music/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/media/marco/Backup/Git/music/node_modules/express/lib/router/index.js:317:13)
at /media/marco/Backup/Git/music/node_modules/express/lib/router/index.js:284:7
at Function.process_params (/media/marco/Backup/Git/music/node_modules/express/lib/router/index.js:335:12)
URIError: Failed to decode param '/%3C%=%20webpackConfig.output.publicPath%20%%3Efavicon.ico'
at decodeURIComponent ()
at decode_param (/media/marco/Backup/Git/music/node_modules/express/lib/router/layer.js:172:12)
at Layer.match (/media/marco/Backup/Git/music/node_modules/express/lib/router/layer.js:123:27)
at matchLayer (/media/marco/Backup/Git/music/node_modules/express/lib/router/index.js:574:18)
at next (/media/marco/Backup/Git/music/node_modules/express/lib/router/index.js:220:15)
at expressInit (/media/marco/Backup/Git/music/node_modules/express/lib/middleware/init.js:40:5)
at Layer.handle [as handle_request] (/media/marco/Backup/Git/music/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/media/marco/Backup/Git/music/node_modules/express/lib/router/index.js:317:13)
at /media/marco/Backup/Git/music/node_modules/express/lib/router/index.js:284:7
at Function.process_params (/media/marco/Backup/Git/music/node_modules/express/lib/router/index.js:335:12)
at next (/media/marco/Backup/Git/music/node_modules/express/lib/router/index.js:275:10)
at query (/media/marco/Backup/Git/music/node_modules/express/lib/middleware/query.js:45:5)
at Layer.handle [as handle_request] (/media/marco/Backup/Git/music/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/media/marco/Backup/Git/music/node_modules/express/lib/router/index.js:317:13)
at /media/marco/Backup/Git/music/node_modules/express/lib/router/index.js:284:7
at Function.process_params (/media/marco/Backup/Git/music/node_modules/express/lib/router/index.js:335:12)

@marco-carvalho
Copy link
Author

right now I just noticed that I created a vue.config.js with baseUrl: "./", and this was happening bcuz of this config

@marco-carvalho
Copy link
Author

marco-carvalho commented Jun 3, 2018

i just removed baseUrl: "./" from vue.config.js and errors in the gh-pages started to happen
https://marco-carvalho.github.io/music/

previously, the baseUrl: "./" solved that problem

@yyx990803
Copy link
Member

yyx990803 commented Jun 3, 2018

baseUrl should be an absolute path from your domain root. ./ is not a valid value. Please read the docs. ./ will break your app when nested assets reference other assets.

@ar53n
Copy link

ar53n commented Jun 4, 2018

@yyx990803 no other possibilities for relative path?
Because this case need when you do not know on what domain it will be. Its only for hash strategy
We could to set in options baseUrl: '', but in vue.config.sj to set baseUrl: '\',

@ffxsam
Copy link
Contributor

ffxsam commented Jul 22, 2018

This error has nothing to do with baseUrl. I'm running into the same issue myself.

@bassplayer7
Copy link

For what its worth, my problem was related to baseUrl, but in a way that I missed initially.

I had a base URL set, like: /app. When I went to localhost:8080, without /app, this error was thrown. When I went to localhost:8080/app, it worked correctly.

@bbugh
Copy link

bbugh commented Aug 27, 2018

This issue is reproducible with a fresh vue-cli 3 project, without making any other changes except to add a bad scss @import path.

It is caused when there's an actual compilation error and you visit the page with a browser. It's pretty confusing since the stack trace and message are unrelated to the actual issue (a missing scss file). I created an example repo for this issue: https://github.com/bbugh/vue-cli-issue-1451

Reproduction steps:

  1. Add a scss @import to the view for a file that doesn't exist:
    <style lang="scss">
    @import "~assets/stylesheets/variables";
    </style>
    
  2. yarn serve
  3. Load localhost:8080 then see the error:
URIError: Failed to decode param '/%3C%=%20BASE_URL%20%%3Efavicon.ico'
    at decodeURIComponent (<anonymous>)
    at decode_param (/Users/bbugh/projects/vue/issue1451/node_modules/express/lib/router/layer.js:172:12)
    at Layer.match (/Users/bbugh/projects/vue/issue1451/node_modules/express/lib/router/layer.js:123:27)
    at matchLayer (/Users/bbugh/projects/vue/issue1451/node_modules/express/lib/router/index.js:574:18)
    at next (/Users/bbugh/projects/vue/issue1451/node_modules/express/lib/router/index.js:220:15)
    at expressInit (/Users/bbugh/projects/vue/issue1451/node_modules/express/lib/middleware/init.js:40:5)
    at Layer.handle [as handle_request] (/Users/bbugh/projects/vue/issue1451/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/Users/bbugh/projects/vue/issue1451/node_modules/express/lib/router/index.js:317:13)
    at /Users/bbugh/projects/vue/issue1451/node_modules/express/lib/router/index.js:284:7
    at Function.process_params (/Users/bbugh/projects/vue/issue1451/node_modules/express/lib/router/index.js:335:12)
    at next (/Users/bbugh/projects/vue/issue1451/node_modules/express/lib/router/index.js:275:10)
    at query (/Users/bbugh/projects/vue/issue1451/node_modules/express/lib/middleware/query.js:45:5)
    at Layer.handle [as handle_request] (/Users/bbugh/projects/vue/issue1451/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/Users/bbugh/projects/vue/issue1451/node_modules/express/lib/router/index.js:317:13)
    at /Users/bbugh/projects/vue/issue1451/node_modules/express/lib/router/index.js:284:7
    at Function.process_params (/Users/bbugh/projects/vue/issue1451/node_modules/express/lib/router/index.js:335:12)

@latel
Copy link

latel commented Sep 10, 2018

frequently here too, no idea what happened, sometimes it's ok, sometimes it's broken.

@ivaaaan
Copy link

ivaaaan commented Dec 10, 2018

I have the same after installing a new package (vuex-class)

@yyx990803
Copy link
Member

On a high level: this error means the URL you are visiting does not have a corresponding HTML page. There could be different causes that leads to this, so the only way to help us investigate the problem is by providing actual reproductions.

@hello2parth
Copy link

+1
I have a similar issue. Don't know the root cause of the same.

@raphaelsaunier
Copy link

I encountered this error as well and in my case it was the symptom of another problem.

The build was failing silently because of a syntax or linter error but vue-cli-service serve didn't show any errors and just served the unprocessed contents of public/index.html.

vue-cli-service build, however, did display the error and I was able to fix it so maybe you could try that?

I'll try to share a minimal code sample to reproduce the error if it happens again!

@jkzing
Copy link
Member

jkzing commented Dec 20, 2018

There are two possible reasons to see this error:

  1. Url visiting in browser doesn't match the baseUrl you specified.

In this situation, seeing this error is because because you are visiting the "original html" (by historyApiFallback), which is not compiled by html-webpack-plugin.

  1. There is a compilation error on first build.

This is because we uses webpack.NoEmitOnErrorsPlugin, which stops html-webpack-plugin from compiling the template.

We can simply remove webpack.NoEmitOnErrorsPlugin to avoid case 2. Is there any special reasons to use it?

@hello2parth
Copy link

There are two possible reasons to see this error:

  1. Url visiting in browser is not match the baseUrl you specified.

In this situation, seeing this error is because because you are visiting the "original html" (by historyApiFallback), which is not compiled by html-webpack-plugin.

  1. There is a compilation error on first build.

This is because we uses webpack.NoEmitOnErrorsPlugin, which stops html-webpack-plugin from compiling the template.

We can simply remove webpack.NoEmitOnErrorsPlugin to avoid case 2. Is there any special reasons to use it?

Yes, You are correct and the error was due to the baseUrl, as development build was not able to take the correct path while running the app in development mode, so I have fixed that by adding below code,

module.exports = {
  baseUrl: process.env.NODE_ENV === 'production'
    ? 'production path'
    : 'development path'
   }

@haoqunjiang
Copy link
Member

@jkzing It was added because of webpack-hot-middleware requires it
vuejs-templates/webpack@7a82c03
I think we can now safely remove it.

@manish87sharma
Copy link

This Issue occurred when you are trying to access the wrong URL.
For example below is my vue.config.js file
chainWebpack: config => {
config.plugin("html").tap(opts => {
opts[0].template = 'public/index.html'
opts[0].title = "V1 Importer Stats";
opts[0].filename = "V1Importer.html";
opts[0].hash = true;
opts[0].favicon = 'public/favicon.ico';
return opts;
});
my index.html file
<link rel="icon" href=<%= htmlWebpackPlugin.options.favicon %>>
<title><%= htmlWebpackPlugin.options.title %></title>

this is what npm run serve do
App running at:

Correct URL is http://localhost:8080/ImporterStats/v1Importer.html because I have replaced it in above html config.

Hope this works for you as well

@Nerphist
Copy link

Nerphist commented Oct 28, 2019

For me it happened because i had
chainWebpack: config => {
config.plugins.delete('html')
config.plugins.delete('preload')
config.plugins.delete('prefetch')
},
from vue.config.js

@vikas-agent
Copy link

xed that by adding below cod

in which file you have added this code

@god-of-js
Copy link

I had this same issue when trying to implement module federation in Vue2

URIError: Failed to decode param '/%3C%=%20BASE_URL%20%%3Efavicon.ico'

I solved it by changing the dynamic code in public\index.html

    <link rel="icon" href="<%= BASE_URL %>favicon.ico">
    <title><%= htmlWebpackPlugin.options.title %></title>

to

    <link rel="icon" href="./favicon.ico">
    <title>Web-common</title>

@Birdknothing
Copy link

Birdknothing commented Oct 10, 2022

it occured when i wanna put all resources in a nested directory in both development and production mode.
i found html-webpack-plugin driven by vue-cli-service failed to find the template html in dev-server. Finally i solved it by adding devMiddleware option in devServer config:

module.exports = {
  publicPath: "./" + process.env.NESTED_DIR_NAME,
  devServer:{
    devMiddleware: {
      publicPath: "/" + process.env.NESTED_DIR_NAME,
    },
  },
  ...
}

by the way, @vue/cli-service should be upgrade to support the "devMiddleware" option,in my case,its ^5.0.0

@Dashsoap
Copy link

Dashsoap commented Oct 10, 2022 via email

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