Github控制台上显示的404错误,带有js载荷。

huangapple go评论53阅读模式
英文:

Github error 404 on console with payload js

问题

我刚刚部署了我的Nuxt应用程序,出现了一些与payload js相关的错误,我不知道这是什么错误。


以下是我的文件目录

Github控制台上显示的404错误,带有js载荷。


我发现payload.js文件中出现错误:...1673214939/<page-name>/payload.js

所有的payload.js文件都包含相同的代码:

__NUXT_JSONP__("/albums", {data:[{}],fetch:{},mutations:[]});

在本地主机上运行正常,但在GitHub上,导航栏中的图标不显示,因为出现了错误。

这是我的nuxt.config.js和package.json文件:

nuxt.config.js

export default {

  head: {
    title: 'Florida',
    htmlAttrs: {
      lang: 'en',
    },
    meta: [
      { charset: 'utf-8' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1' },
      { hid: 'description', name: 'description', content: '' },
      { name: 'format-detection', content: 'telephone=no' },
    ],
    link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }],
  },

  target: 'static',
  router: {
    base: '/FloridaGifts/'
  },

  css: ["./assets/main.scss"],

  plugins: [
    {
      src: './plugins/vue-icons.js',
      mode: 'client'
    },
  ],

  components: true,

  buildModules: [
    '@nuxtjs/eslint-module',
    '@nuxtjs/dotenv'
  ],

  modules: [
    'bootstrap-vue/nuxt',
    '@nuxtjs/axios',
    [
      '@nuxtjs/firebase',

      {
        config: {
          apiKey: process.env.API_KEY,
          authDomain: process.env.AUTH_DOMAIN,
          databaseURL: process.env.DATABASE_URL,
          projectId: process.env.PROJECT_ID,
          storageBucket: process.env.STORAGE_BUCKET,
          messagingSenderId: process.env.MESSAGING_SENDER_ID,
          appId: process.env.APP_ID,
          measurementId: process.env.MEASUREMENT_ID
        },

        services: {
          auth: {
            initialize: {
              onAuthStateChangedAction: 'onAuthStateChangedAction',
            }
          },
          database: true,
          storage: true
        }
      }
    ]
  ],

  axios: {
    baseURL: '/',
  },

  build: {},
}

package.json

{
  "name": "client",
  "version": "1.0.0",
  "private": true,
  "scripts": {
    "dev": "nuxt",
    "build": "nuxt build",
    "start": "nuxt start",
    "generate": "nuxt generate",
    "deploy": "push-dir --dir=dist --branch=gh-pages --cleanup",
    "lint:js": "eslint --ext \".js,.vue\" --ignore-path .gitignore .",
    "lint:prettier": "prettier --check .",
    "lint": "npm run lint:js && npm run lint:prettier",
    "lintfix": "prettier --write --list-different . && npm run lint:js -- --fix",
    "test": "jest"
  },
  "dependencies": {
    "@nuxtjs/axios": "^5.13.6",
    "@nuxtjs/dotenv": "^1.4.1",
    "@nuxtjs/firebase": "^8.2.2",
    "bootstrap": "^4.6.2",
    "bootstrap-vue": "^2.22.0",
    "core-js": "^3.25.3",
    "hooper": "^0.3.4",
    "nuxt": "^2.15.8",
    "vue": "^2.7.10",
    "vue-server-renderer": "^2.7.10",
    "vue-template-compiler": "^2.7.10"
  },
  "devDependencies": {
    "@babel/eslint-parser": "^7.19.1",
    "@nuxtjs/eslint-config": "^11.0.0",
    "@nuxtjs/eslint-module": "^3.1.0",
    "@vue/test-utils": "^1.3.0",
    "babel-core": "7.0.0-bridge.0",
    "babel-jest": "^29.1.2",
    "eslint": "^8.24.0",
    "eslint-config-prettier": "^8.5.0",
    "eslint-plugin-jest": "^27.0.4",
    "eslint-plugin-nuxt": "^4.0.0",
    "eslint-plugin-vue": "^9.5.1",
    "jest": "^29.1.2",
    "jest-environment-jsdom": "^29.1.2",
    "prettier": "^2.7.1",
    "push-dir": "^0.4.1",
    "sass": "^1.56.1",
    "sass-loader": "^10.4.1",
    "vue-jest": "^3.0.4",
    "webpack": "^4.45.0"
  }
}

在部署时,我运行了以下命令:

npm run generate
npm install push-dir --save-dev
npm run generate
npm run deploy

仓库链接:仓库

gh-pages(部署)链接:部署

开发中的警告:

Github控制台上显示的404错误,带有js载荷。

Github控制台上显示的404错误,带有js载荷。

Github控制台上显示的404错误,带有js载荷。

DOM不匹配错误的源代码:

else if (hasConsole_1 && !config.silent) {
  console.error("[Vue warn]: " + msg + trace);
}
英文:

Github控制台上显示的404错误,带有js载荷。

I have just deployed my Nuxt app and there are some errors with payload js, I have no idea what error is this.


Here is my file directory

Github控制台上显示的404错误,带有js载荷。


I found that payload.js file which is in error: ...1673214939/&lt;page-name&gt;/payload.js

and there is in all payload.js files same code:

__NUXT_JSONP__(&quot;/albums&quot;, {data:[{}],fetch:{},mutations:[]});

It is working well on localhost but in github, icons in Navbar are not apearing because of errors.

There my nuxt.config.js and package.json files:

nuxt.config.js:

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-js -->

export default {
head: {
title: &#39;Florida&#39;,
htmlAttrs: {
lang: &#39;en&#39;,
},
meta: [
{ charset: &#39;utf-8&#39; },
{ name: &#39;viewport&#39;, content: &#39;width=device-width, initial-scale=1&#39; },
{ hid: &#39;description&#39;, name: &#39;description&#39;, content: &#39;&#39; },
{ name: &#39;format-detection&#39;, content: &#39;telephone=no&#39; },
],
link: [{ rel: &#39;icon&#39;, type: &#39;image/x-icon&#39;, href: &#39;/favicon.ico&#39; }],
},
target: &#39;static&#39;,
router: {
base: &#39;/FloridaGifts/&#39;
},
css: [&quot;./assets/main.scss&quot;],
plugins: [
{
src: &#39;./plugins/vue-icons.js&#39;,
mode: &#39;client&#39;
},
],
components: true,
buildModules: [
&#39;@nuxtjs/eslint-module&#39;,
&#39;@nuxtjs/dotenv&#39;
],
modules: [
&#39;bootstrap-vue/nuxt&#39;,
&#39;@nuxtjs/axios&#39;,
[
&#39;@nuxtjs/firebase&#39;,
{
config: {
apiKey: process.env.API_KEY,
authDomain: process.env.AUTH_DOMAIN,
databaseURL: process.env.DATABASE_URL,
projectId: process.env.PROJECT_ID,
storageBucket: process.env.STORAGE_BUCKET,
messagingSenderId: process.env.MESSAGING_SENDER_ID,
appId: process.env.APP_ID,
measurementId: process.env.MEASURMENT_ID
},
services: {
auth: {
initialize: {
onAuthStateChangedAction: &#39;onAuthStateChangedAction&#39;,
}
},
database: true,
storage: true
}
}
]
],
axios: {
baseURL: &#39;/&#39;,
},
build: {},
}

<!-- end snippet -->

package.json:

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-json -->

{
&quot;name&quot;: &quot;client&quot;,
&quot;version&quot;: &quot;1.0.0&quot;,
&quot;private&quot;: true,
&quot;scripts&quot;: {
&quot;dev&quot;: &quot;nuxt&quot;,
&quot;build&quot;: &quot;nuxt build&quot;,
&quot;start&quot;: &quot;nuxt start&quot;,
&quot;generate&quot;: &quot;nuxt generate&quot;,
&quot;deploy&quot;: &quot;push-dir --dir=dist --branch=gh-pages --cleanup&quot;,
&quot;lint:js&quot;: &quot;eslint --ext \&quot;.js,.vue\&quot; --ignore-path .gitignore .&quot;,
&quot;lint:prettier&quot;: &quot;prettier --check .&quot;,
&quot;lint&quot;: &quot;npm run lint:js &amp;&amp; npm run lint:prettier&quot;,
&quot;lintfix&quot;: &quot;prettier --write --list-different . &amp;&amp; npm run lint:js -- --fix&quot;,
&quot;test&quot;: &quot;jest&quot;
},
&quot;dependencies&quot;: {
&quot;@nuxtjs/axios&quot;: &quot;^5.13.6&quot;,
&quot;@nuxtjs/dotenv&quot;: &quot;^1.4.1&quot;,
&quot;@nuxtjs/firebase&quot;: &quot;^8.2.2&quot;,
&quot;bootstrap&quot;: &quot;^4.6.2&quot;,
&quot;bootstrap-vue&quot;: &quot;^2.22.0&quot;,
&quot;core-js&quot;: &quot;^3.25.3&quot;,
&quot;hooper&quot;: &quot;^0.3.4&quot;,
&quot;nuxt&quot;: &quot;^2.15.8&quot;,
&quot;vue&quot;: &quot;^2.7.10&quot;,
&quot;vue-server-renderer&quot;: &quot;^2.7.10&quot;,
&quot;vue-template-compiler&quot;: &quot;^2.7.10&quot;
},
&quot;devDependencies&quot;: {
&quot;@babel/eslint-parser&quot;: &quot;^7.19.1&quot;,
&quot;@nuxtjs/eslint-config&quot;: &quot;^11.0.0&quot;,
&quot;@nuxtjs/eslint-module&quot;: &quot;^3.1.0&quot;,
&quot;@vue/test-utils&quot;: &quot;^1.3.0&quot;,
&quot;babel-core&quot;: &quot;7.0.0-bridge.0&quot;,
&quot;babel-jest&quot;: &quot;^29.1.2&quot;,
&quot;eslint&quot;: &quot;^8.24.0&quot;,
&quot;eslint-config-prettier&quot;: &quot;^8.5.0&quot;,
&quot;eslint-plugin-jest&quot;: &quot;^27.0.4&quot;,
&quot;eslint-plugin-nuxt&quot;: &quot;^4.0.0&quot;,
&quot;eslint-plugin-vue&quot;: &quot;^9.5.1&quot;,
&quot;jest&quot;: &quot;^29.1.2&quot;,
&quot;jest-environment-jsdom&quot;: &quot;^29.1.2&quot;,
&quot;prettier&quot;: &quot;^2.7.1&quot;,
&quot;push-dir&quot;: &quot;^0.4.1&quot;,
&quot;sass&quot;: &quot;^1.56.1&quot;,
&quot;sass-loader&quot;: &quot;^10.4.1&quot;,
&quot;vue-jest&quot;: &quot;^3.0.4&quot;,
&quot;webpack&quot;: &quot;^4.45.0&quot;
}
}

<!-- end snippet -->

And when I was deploying it, I have run these commands

npm run generate
npm install push-dir --save-dev

npm run generate
npm run deploy

link to repository: repository

link to gh-pages(deploy): deploy

Warnings in dev:

Github控制台上显示的404错误,带有js载荷。

Github控制台上显示的404错误,带有js载荷。

Github控制台上显示的404错误,带有js载荷。

Source of DOM missmatch error:

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-js -->

else if (hasConsole_1 &amp;&amp; !config.silent) {
console.error(&quot;[Vue warn]: &quot;.concat(msg).concat(trace));
}

<!-- end snippet -->

答案1

得分: 1

OP按照此处建议解决了问题,使用了client-only:https://stackoverflow.com/a/67978474/8816585

在使用v-for时修复一些唯一ID键也有所帮助。

我还推荐此解决方案以实现一种通用的图标使用方式,避免了设置和处理各种怪癖所带来的痛苦。

英文:

OP solved the issue with a client-only as proposed here: https://stackoverflow.com/a/67978474/8816585

Fixing some unique ID keys while using v-for also helped.

I also recommend this solution to have a universal way of using icons without all the pain or setting it up and dealing with various quirks.

huangapple
  • 本文由 发表于 2023年1月9日 06:24:54
  • 转载请务必保留本文链接:https://go.coder-hub.com/75051690.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定