質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.46%
Nuxt.js

Nuxt.jsは、ユニバーサルなSPAが開発可能なVue.jsベースのフレームワーク。UIの描画サポートに特化しており、SSRにおけるサーバーサイドとクライアントサイドのUIレンダリングなどさまざまな機能を持ちます。

Q&A

0回答

1017閲覧

nuxtサブディレクトリにデプロイ

sosososo

総合スコア18

Nuxt.js

Nuxt.jsは、ユニバーサルなSPAが開発可能なVue.jsベースのフレームワーク。UIの描画サポートに特化しており、SSRにおけるサーバーサイドとクライアントサイドのUIレンダリングなどさまざまな機能を持ちます。

0グッド

0クリップ

投稿2021/12/26 07:40

編集2021/12/27 09:45

nuxtでアプリを作成しXserverで公開しようとしています。
エラーが出てしまい解決方法がわかりません。
教えて頂けますでしょうか。

npm run generateで作成されたdistフォルダ(diagnosticsで出力されるようにnuxt.config.jsで修正)をXServerのルートディレクトリpublic_htmlにアップロードした。
ブラウザからhttp://************.com/diagnostic/にアクセスするとnuxtのエラーページが出てきて、コンソール画面には下記画像のエラーが表示されています。
CONNECTION_REFUSEDが発生しているquestion.jsonですが、そのファイルは diagnosticフォルダ→jsonフォルダ内にあります。ですがコンソール画面ではlocalhost:3000/json/questions.jsonとなっており、これがエラーの原因だと思うのですが、解決方法がわかりません。
index.vueではこのロードの箇所はscript内に下記のように記述しています。

js

1 async asyncData({ $axios }) { 2 const questions = await $axios.$get('json/questions.json'); 3 return { 4 questions: questions, 5 } 6 }, 7

教えていただけますと助かります。

js

1// nuxt.config.js 2import colors from 'vuetify/es5/util/colors' 3import path from 'path' 4import fs from 'fs' 5 6 7export default { 8 9 plugins: [ 10 '/plugins/urls', 11 ], 12 13 // Disable server-side rendering: https://go.nuxtjs.dev/ssr-mode 14 ssr: false, 15 16 // Target: https://go.nuxtjs.dev/config-target 17 target: 'static', 18 19 build: { 20 publicPath: '/static/' 21 }, 22 23 generate: { 24 dir: 'diagnostic' 25 }, 26 27 // Global page headers: https://go.nuxtjs.dev/config-head 28 head: { 29 titleTemplate: '%s - 診断テスト', 30 title: '診断テスト', 31 htmlAttrs: { 32 lang: 'ja' 33 }, 34 meta: [ 35 { charset: 'utf-8' }, 36 { name: 'viewport', content: 'width=device-width, initial-scale=1' }, 37 { hid: 'description', name: 'description', content: '' }, 38 { name: 'format-detection', content: 'telephone=no' } 39 ], 40 link: [ 41 { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' } 42 ], 43 script: [ 44 { 45 src: 'https://smtpjs.com/v3/smtp.js' 46 } 47 ], 48 }, 49 50 router: { 51 base: '/diagnostic/', 52 trailingSlash: true 53 }, 54 55 // Global CSS: https://go.nuxtjs.dev/config-css 56 css: [ 57 ], 58 59 // Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins 60 plugins: [ 61 ], 62 63 // Auto import components: https://go.nuxtjs.dev/config-components 64 components: true, 65 66 // Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules 67 buildModules: [ 68 // https://go.nuxtjs.dev/vuetify 69 '@nuxtjs/vuetify', 70 ], 71 72 // Modules: https://go.nuxtjs.dev/config-modules 73 modules: [ 74 "@nuxtjs/axios" 75 ], 76 77 // Vuetify module configuration: https://go.nuxtjs.dev/config-vuetify 78 vuetify: { 79 customVariables: ['~/assets/variables.scss'], 80 theme: { 81 dark: false, 82 themes: { 83 dark: { 84 primary: "#FFAB2D", 85 accent: colors.grey.darken3, 86 secondary: colors.amber.darken3, 87 info: colors.teal.lighten1, 88 warning: colors.amber.base, 89 error: colors.deepOrange.accent4, 90 success: colors.green.accent3 91 }, 92 light: { 93 primary: "#FFAB2D", 94 accent: colors.grey.darken3, 95 secondary: colors.amber.darken3, 96 info: colors.teal.lighten1, 97 warning: colors.amber.base, 98 error: colors.deepOrange.accent4, 99 success: colors.green.accent3 100 } 101 102 } 103 } 104 }, 105 106 107} 108

#ブラウザ コンソール
イメージ説明

以上よろしくおねがいします。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.46%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問