Home > other >  Duplicate <link rel='preload'> and <script>, Browser warning to add "cros
Duplicate <link rel='preload'> and <script>, Browser warning to add "cros

Time:08-04

Got a Nuxt project where I am getting errors about some preloaded files not having crossorigin and as parameters.

Not sure if it is a NUXT specific bug or some package? I deleted all my preload and prefetch code to see if it will give any difference, but nothing changed.

enter image description here

asked same question in NUXT community enter image description here

After some research I found out that the problem is related to webpack and can be potentially fixed by output.crossOriginLoading https://webpack.js.org/configuration/output/ Which I tried to apply in my nuxt.config.ts like so:

  target: "static", <-----tried both static and server
  output: {
    crossOriginLoading: "anonymous",
  },

Nothing works. After navigating to the link in Chrome browser I can see that webpack's JSONP is used to build chunks.

window["webpackJsonp"] = window["webpackJsonp"]

Is it used by default in NUXT?

UPDATE:

Apparently I have script tags with "as" in the page source. Wondering why the warning still appearing in the console

 <link rel="preload" href="/_nuxt/app~._.nuxt_A.js" as="script" />
    <link rel="preload" href="/_nuxt/app~._.nuxt_A.css" as="style" />
    <link rel="preload" href="/_nuxt/app~._a.css" as="style" />
    <link rel="preload" href="/_nuxt/app~._a.js" as="script" />
    <link rel="preload" href="/_nuxt/app~._l.js" as="script" />
    <link rel="preload" href="/_nuxt/app~._layouts_d.js" as="script" />
    <link rel="preload" href="/_nuxt/app~._n.js" as="script" />
    <link
      rel="preload"
      href="/_nuxt/app~._node_modules_atlas_node_modules_vue_dist_vue.runtime.esm.js~8cb01656.js"
      as="script"
    />
    <link
      rel="preload"
      href="/_nuxt/app~._node_modules_atlas_src_c.js"
      as="script"
    />
    <link rel="preload" href="/_nuxt/app~._node_modules_ba.js" as="script" />
    <link rel="preload" href="/_nuxt/app~._node_modules_c.js" as="script" />
    <link rel="preload" href="/_nuxt/app~._node_modules_h.js" as="script" />
    <link rel="preload" href="/_nuxt/app~._node_modules_i.js" as="script" />
    <link rel="preload" href="/_nuxt/app~._node_modules_vue-c.js" as="script" />
    <link
      rel="preload"
      href="/_nuxt/app~._node_modules_vue_dist_vue.runtime.esm.js~6acccc03.js"
      as="script"
    />
    <link
      rel="preload"
      href="/_nuxt/header-bar-mobile-menu~._node_modules_atlas_src_components_HeaderBar_HeaderBarMobileMenu.vue~0.js"
      as="script"
    />
    <link rel="preload" href="/_nuxt/pages/index~._c.css" as="style" />
    <link rel="preload" href="/_nuxt/pages/index~._c.js" as="script" />
    <link
      rel="preload"
      href="/_nuxt/pages/_~pages/index~pages/preview/_~pages/search~._c.js"
      as="script"
    />
    <link rel="preload" href="/_nuxt/0.js" as="script" />

Opened issue on nuxt.js github page https://github.com/nuxt/nuxt.js/issues/10613

CodePudding user response:

This behaviour is a bug in NUXT Bridge and will be fixed by NUXT when they upgrade to the new version of vue-bundle-renderer.

link to the issue: https://github.com/nuxt/bridge/issues/453

  • Related