nuxt / nuxt/image

Generate adds double slashes when using build.publicPath with domain

Open
#463 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

v0
Dominant language
TypeScript
Stars
1.5k
Forks
331
Avg merge
19h 52m
Merged PRs (30d)
9

Description

Hello,

We are using the Images module to convert static images to Webp format.
We want to serve static files from other domain, so as I understand that we need to change build.publicPath to serve all static files from other domain.

Here are our settings:

// packages.json

"dependencies": {
  "@nuxtjs/i18n": "^7.2.0",
  "@nuxtjs/sentry": "^5.1.6",
  "core-js": "^3.17.1",
  "nuxt": "^2.15.8"
},
"devDependencies": {
  "@mdi/js": "^6.4.95",
  "@nuxt/image": "^0.6.0",
  "@nuxt/types": "^2.15.8",
  "@nuxtjs/pwa": "^3.3.5",
  "@nuxtjs/vuetify": "^1.12.1",
  "@vue/test-utils": "^1.2.1",
  "babel-core": "7.0.0-bridge.0",
  "babel-jest": "^27.0.5",
  "jest": "^27.0.5",
  "nuxt-purgecss": "^1.0.0",
  "vue-jest": "^3.0.4",
  "webpack": "^4.46.0"
}
// nuxt.config.js

ssr: true,

target: 'static',

. . .

buildModules: [
  '@nuxt/image',
],

. . .

image: {
  dir: 'assets/images'
},

. . .

build: {
  extractCSS: {
    ignoreOrder: true
  },
  publicPath: process.env.NODE_ENV === 'production' ? 'https://static.domain.com/_nuxt/' : '/_nuxt/'
}

Unfortunately, after the generate, I see a tag like this.

<img src="https://static.domain.com/_nuxt//image/4bf726.webp" width="187" height="80" loading="eager" sizes="600px" srcset="https://static.domain.com/_nuxt//image/4bf726.webp 600w" data-v-8380cc7e>

I'm pretty sure those double slashes (_nuxt//image) should not be there.

Without a domain (publicPath: '/some/random/path/'), there are no double slashes added and everything is correct.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the generated output using the issue's nuxt.config.js settings, especially @nuxt/image and build.publicPath. Trace how the generated image URL combines https://static.domain.com/_nuxt/ with /image/4bf726.webp, then verify the result no longer contains _nuxt//image while still using the configured domain and path.

Written by the indexing model from the issue text.

Assessment

Tech stack
nuxtjs, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.