前提・実現したいこと
Vue.js(webpack)+Railsで作ったアプリをデブロイしたいですが、下記のエラーが出て画面が真っ白になります。
開発環境ではこれで動いていたのですが、デプロイしたらエラーとなりました。
パスがダメなのでしょうか。
アドバイスを頂けますと幸いです。
発生している問題・エラーメッセージ
Refused to execute script from 'http://35.72.231.182/packs/js/application-5acf42d4f22c38728cd2.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
Refused to execute script from 'http://35.72.231.182/packs/js/hello_vue-dd3c16389c86e14ad8ad.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled. # MIMEタイプ(「text / html」)が実行可能ではなく、厳密なMIMEタイプチェックが有効になっているため、「http://35.72.231.182/packs/js/application-5acf42d4f22c38728cd2.js」からのスクリプトの実行を拒否しました。
該当のソースコード
ディレクトリ
. ├── Gemfile ├── Gemfile.lock ├── Procfile ├── README.md ├── Rakefile ├── app │ ├── assets │ ├── channels │ ├── controllers │ ├── helpers │ ├── javascript │ ├── jobs │ ├── mailers │ ├── models │ └── views ├── babel.config.js ├── bin │ ├── rails │ ├── rake │ ├── setup │ ├── webpack │ ├── webpack-dev-server │ └── yarn ├── config │ ├── application.rb │ ├── boot.rb │ ├── cable.yml │ ├── credentials.yml.enc │ ├── database.yml │ ├── environment.rb │ ├── environments │ ├── initializers │ ├── locales │ ├── puma.rb │ ├── routes.rb │ ├── spring.rb │ ├── storage.yml │ ├── webpack │ └── webpacker.yml ├── config.ru ├── db ├── lib ├── log ├── node_modules ├── package.json ├── postcss.config.js ├── public │ ├── 404.html │ ├── 422.html │ ├── 500.html │ ├── apple-touch-icon-precomposed.png │ ├── apple-touch-icon.png │ ├── favicon.ico │ ├── header_logo.png │ ├── packs │ ├── packs-test │ └── robots.txt ├── spec ├── storage ├── tmp │ ├── cache │ ├── development_secret.txt │ ├── pids │ ├── restart.txt │ ├── screenshots │ └── sockets ├── vendor │ └── bundle ├── yarn-error.log └── yarn.lock
application.html.erb
ruby
1<!DOCTYPE html> 2<html> 3 <head> 4 <meta name="viewport" content="width=device-width,initial-scale=1.0"> 5 <title>BestGifter</title> 6 <%= csrf_meta_tags %> 7 <%= csp_meta_tag %> 8 <%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %> 9 </head> 10 11 <body> 12 <%= yield %> 13 </body> 14</html> 15
config/webpacker.yml
# Note: You must restart bin/webpack-dev-server for changes to take effect default: &default source_path: app/javascript source_entry_path: packs public_root_path: public public_output_path: packs cache_path: tmp/cache/webpacker check_yarn_integrity: false webpack_compile_output: true # Additional paths webpack should lookup modules # ['app/assets', 'engine/foo/app/assets'] resolved_paths: [] # Reload manifest.json on all requests so we reload latest compiled packs cache_manifest: false # Extract and emit a css file extract_css: false static_assets_extensions: - .jpg - .jpeg - .png - .gif - .tiff - .ico - .svg - .eot - .otf - .ttf - .woff - .woff2 extensions: - .vue - .mjs - .js - .sass - .scss - .css - .module.sass - .module.scss - .module.css - .png - .svg - .gif - .jpeg - .jpg development: <<: *default compile: true # Verifies that correct packages and versions are installed by inspecting package.json, yarn.lock, and node_modules check_yarn_integrity: true # Reference: https://webpack.js.org/configuration/dev-server/ dev_server: https: false host: localhost port: 3035 public: localhost:3035 hmr: false # Inline should be set to true if using HMR inline: true overlay: true compress: true disable_host_check: true use_local_ip: false quiet: false pretty: false headers: 'Access-Control-Allow-Origin': '*' watch_options: ignored: '**/node_modules/**' test: <<: *default compile: true # Compile test packs to a separate directory public_output_path: packs-test production: <<: *default # Production depends on precompilation of packs prior to booting for performance. compile: false # Extract and emit a css file extract_css: true # Cache manifest.json for performance cache_manifest: true
public/packs/manifest.json
{ "application.js": "/packs/js/application-5acf42d4f22c38728cd2.js", "application.js.map": "/packs/js/application-5acf42d4f22c38728cd2.js.map", "entrypoints": { "application": { "js": [ "/packs/js/application-5acf42d4f22c38728cd2.js" ], "js.map": [ "/packs/js/application-5acf42d4f22c38728cd2.js.map" ] }, "hello_vue": { "js": [ "/packs/js/hello_vue-dd3c16389c86e14ad8ad.js" ], "js.map": [ "/packs/js/hello_vue-dd3c16389c86e14ad8ad.js.map" ] } }, "hello_vue.js": "/packs/js/hello_vue-dd3c16389c86e14ad8ad.js", "hello_vue.js.map": "/packs/js/hello_vue-dd3c16389c86e14ad8ad.js.map", "media/fonts/materialdesignicons-webfont.eot": "/packs/media/fonts/materialdesignicons-webfont-3d1f8fa2.eot", "media/fonts/materialdesignicons-webfont.ttf?v=5.8.55": "/packs/media/fonts/materialdesignicons-webfont-3e722fd5.ttf", "media/fonts/materialdesignicons-webfont.woff2?v=5.8.55": "/packs/media/fonts/materialdesignicons-webfont-4187121a.woff2", "media/fonts/materialdesignicons-webfont.woff?v=5.8.55": "/packs/media/fonts/materialdesignicons-webfont-fec1b66a.woff", "media/images/catalog.jpg": "/packs/media/images/catalog-b105e2d9.jpg", "media/images/daily_necessaries.jpg": "/packs/media/images/daily_necessaries-8416c3cb.jpg", "media/images/empty.jpg": "/packs/media/images/empty-922d19bd.jpg", "media/images/flower.jpg": "/packs/media/images/flower-f59c0023.jpg", "media/images/gift_certificate.jpg": "/packs/media/images/gift_certificate-f9935ece.jpg", "media/images/home_electriv_appliances.jpg": "/packs/media/images/home_electriv_appliances-a616249b.jpg", "media/images/interior.jpg": "/packs/media/images/interior-2cb604c9.jpg", "media/images/kitchen_goods.jpg": "/packs/media/images/kitchen_goods-049761b4.jpg", "media/images/logo_header.JPG": "/packs/media/images/logo_header-7ec3eb7a.JPG", "media/images/logo_light_pink.JPG": "/packs/media/images/logo_light_pink-613dd90a.JPG", "media/images/logo_medium_pink.JPG": "/packs/media/images/logo_medium_pink-c338e45b.JPG", "media/images/logo_no_color.JPG": "/packs/media/images/logo_no_color-e1e3b488.JPG", "media/images/loungwear.jpg": "/packs/media/images/loungwear-5d882a61.jpg", "media/images/person-circle.svg": "/packs/media/images/person-circle-d2b1b7fe.svg", "media/images/top_image.jpg": "/packs/media/images/top_image-0d9c05bc.jpg", "media/images/top_image_pink.JPG": "/packs/media/images/top_image_pink-a5c01987.JPG", "media/images/wine.jpg": "/packs/media/images/wine-dcf7bf09.jpg" }
試したこと
type="text/javascript"
を追加してみてもダメでしたので、パスがだめなのかと思っています。
application.html.erb
ruby
1 <%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload', type="text/javascript" %> 2
補足情報(FW/ツールのバージョンなど)
Rails 6.0.3.4
Vue 2.6.2
"webpack-dev-server": "^3.11.1"
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。