programing

NUXT - 리소스 로드 실패: 서버가 404 상태로 응답했습니다.

prostudy 2022. 7. 31. 21:18
반응형

NUXT - 리소스 로드 실패: 서버가 404 상태로 응답했습니다.

nuxt create-app 도입에 어려움을 겪고 있습니다.

사실, 내가 달릴 때$ npm run generate잘못된 경로를 가진 dist 폴더를 생성합니다._nuxt/폴더입니다.

.html 파일의 올바른 상대 경로를 입력한다._nuxt/test.js가 아니라/_nuxt/test.js(첫 번째 "/"는 생략). 루트 디렉토리에서 파일을 검색하기 때문입니다.

이미 몇 시간이고 찾아봤지만 유효한 해결책을 찾을 수가 없어요.SSR 모드에서 nuxtjs 사이트를 게시할 때 이 오류를 발견했는데, 실제로 구현 방법을 이해하지 못했습니다. ngix란 무엇입니까? 수정해야 하는 파일은 무엇입니까?몰라.

여기 nuxt.config.js 아래

const pkg = require('./package')

module.exports = {
  mode: 'universal',

  /*
  ** Headers of the page
  */
  head: {
    title: pkg.name,
    meta: [
      { charset: 'utf-8' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1' },
      { hid: 'description', name: 'description', content: pkg.description },
      { hid: 'keywords', name: 'keywords', content: 'pellet, pellets, madrid, cuenca, segovia, toledo, guadalajara' }
    ],
    link: [
      { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' },
      { rel: 'stylesheet', href: 'https://fonts.googleapis.com/css?family=Merriweather|Open+Sans'},
      { rel: 'stylesheet', href: 'assets/fonts/fontawesome/css/all.css'}
    ]
  },

  /*
  ** Customize the progress-bar color
  */
  loading: { color: '#fff' },

  /*
  ** Global CSS
  */
  css: [
    // SCSS file in the project
    '@/assets/css/main.scss'
  ],

  /*
  ** Plugins to load before mounting the App
  */
  plugins: [
    '@/plugins/vee-validate'
  ],

  /*
  ** Nuxt.js modules
  */
  modules: [
    // Doc: https://axios.nuxtjs.org/usage
    '@nuxtjs/axios',
    // Doc: https://bootstrap-vue.js.org/docs/
    'bootstrap-vue/nuxt'
  ],
  /*
  ** Axios module configuration
  */
  axios: {
    // See https://github.com/nuxt-community/axios-module#options
  },

  /*
  ** Build configuration
  */
  build: {

    /*
    ** You can extend webpack config here
    */
    extend(config, ctx) {
      // Run ESLint on save
      if (ctx.isDev && ctx.isClient) {
        config.module.rules.push({
          enforce: 'pre',
          test: /\.(js|vue)$/,
          loader: 'eslint-loader',
          exclude: /(node_modules)/,
          options : {
            fix : true
          }
        })
      }
    },

    /*
    ** POST CSS 
    */
    postcss: {
      // Add plugin names as key and arguments as value
      // Install them before as dependencies with npm or yarn
      //postcss-loader autoprefixer
      plugins: {
       // Disable a plugin by passing false as value 
       // 'postcss-url': false,
       // 'postcss-nested': false,
       // 'postcss-responsive-type': false,
        'postcss-hexrgba': {}
      },
      preset: {
        // Change the postcss-preset-env settings
        autoprefixer: {
          grid: true
        }
      }
    }

  }
}

이 악몽을 해결할 수 있도록 도와주세요.대단히 고맙습니다,

빌드 설정으로 Hasan이 어떻게 처리되는지 잘 모르겠습니다.publicPath"public"으로 표시됩니다.

저 같은 경우에는 방금 교체했습니다.public/와 함께.nuxt/dist/client/나한테는 잘된 것 같아요.

추신.nuxt/ 보이지 않는 폴더입니다.

프로덕션용 개별 파일을 생성하고 다시 빌드해야 합니다.

  1. pm2 init (이 에코시스템 구성 파일 작성 후)
  2. pm2 시작

응용 프로그램이 도메인에서 성공적으로 실행되었습니다.

언급URL : https://stackoverflow.com/questions/54615007/nuxt-failed-to-load-resource-the-server-responded-with-a-status-of-404

반응형