nuxt / nuxt/bridge

When configured with bridge.vite.legacy=true client scripts crash if the page has img tags with /static/ sources

Open
#1,322 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: Darwin
  • Node Version: v18.20.4
  • Nuxt Version: 2.17.3
  • CLI Version: 3.14.0
  • Nitro Version: 2.9.7
  • Package Manager: npm@10.7.0
  • Builder: webpack
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -
Reproduction

Set up Nuxt2 default project, and migrate into @nuxt/bridge
https://nuxt.com/docs/bridge/overview

Configure as follows

import { defineNuxtConfig } from '@nuxt/bridge'

export default defineNuxtConfig({
  bridge: {
    typescript: true,
    nitro: true,
    meta: false,
    vite: {
      legacy: false,
    },
  }
})

Place an image in /static/logo-green-white.png

And page component file:

<template>
  <div>
    <img src="/logo-green-white.png" alt="">
    <span v-if="isLoadingDone">done</span>
    <span v-else>not done</span>
  </div>
</template>

<script lang="ts">
import Vue from 'vue'

export default Vue.extend({
  name: 'IndexPage',
  data() {
    return {
      isLoadingDone: false
    };
  },
  mounted() {
    setTimeout(() => {
      this.isLoadingDone = true
    }, 5000)
  },
})
</script>

Production build and run
npm run build && npm run start

Describe the bug

Output to console.log

TypeError: globalThis.__publicAssetsURL is not a function
    at index-DVkd1gRf.js:1:190

And the execution of the script on that page will be stopped. The display should change to done after 5 seconds, but it does not.

Additional context

No response

Logs
TypeError: globalThis.__publicAssetsURL is not a function
    at index-DVkd1gRf.js:1:190

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 with the bridge configuration in nuxt.config.ts and the reproduction page in index.vue, then run npm run build && npm run start. Verify the generated client script no longer throws the __publicAssetsURL error and that the page changes from “not done” to “done” after five seconds.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.