nuxt / nuxt/bridge

When nitro is turned on and cdnURL is used, an error occurs in the resource path when the resource dynamically imported by webpack is loaded on the client.

Open
#1,668 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

pending triage
Dominant language
TypeScript
Stars
285
Forks
33
Avg merge
22h 38m
Merged PRs (30d)
3

Description

Environment

  • Operating System: Linux
  • Node Version: v22.12.0
  • Nuxt Version: 2.18.1
  • CLI Version: 3.30.0
  • Nitro Version: 2.12.5
  • Package Manager: yarn@1.22.22
  • Builder: webpack
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Reproduction
Describe the bug
export default defineNuxtConfig({
    app: { cdnURL: 'http://static.local.jeeda.net' },
    bridge: {
            capi: { legacy: false },
            typescript: true,
            nitro: true,
            transpile: true,
            meta: true,
            vite: false,
    },
    nitro: {
        ....
    }
})
Image

When I configure cdnURL and enable nitro, I can find that cdnURL also covers build.publicPath through the setupNitroBridge function in bridge/src/nitro.ts. At the same time, publicPath will take effect in the webpack build. You can see it by printing config from the build.extend configuration.

Image

Eventually this will lead to a problem: resources dynamically loaded through webpack will have path splicing errors, like this
Image

Additional context

No response

Logs

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

Start in bridge/src/nitro.ts, especially setupNitroBridge, and inspect how app.cdnURL is propagated to build.publicPath and then used by webpack. Reproduce the configuration with Nitro enabled and webpack selected, then verify that client-side dynamically imported resources resolve without the path-splicing error.

Written by the indexing model from the issue text.

Assessment

Tech stack
nuxt, typescript, webpack
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.