実現したいこと
HerokuにてLaravelで開発したWebアプリを公開したい。
前提
Webアプリのコードはここに載っています。
https://github.com/saitousan1127/example-app/actions/runs/5435497860/jobs/9884656403
プッシュ&コミット、デプロイまでは出来ました。
発生している問題・エラーメッセージ
デプロイしたアプリにアクセスしてみても「404|NotFound」というページが表示されていしまう。
↓Application Logs
2023-07-02T08:24:11.489544+00:00 app[web.1]: DOCUMENT_ROOT changed to 'public/' 2023-07-02T08:24:11.539966+00:00 app[web.1]: Detected 536870912 Bytes of RAM 2023-07-02T08:24:11.562224+00:00 app[web.1]: PHP memory_limit is 128M Bytes 2023-07-02T08:24:11.570660+00:00 app[web.1]: Starting php-fpm with 4 workers... 2023-07-02T08:24:11.625176+00:00 app[web.1]: Starting httpd... 2023-07-02T08:24:12.172618+00:00 heroku[web.1]: State changed from starting to up 2023-07-02T08:25:19.454970+00:00 app[web.1]: 10.1.30.231 - - [02/Jul/2023:08:25:19 +0000] "GET / HTTP/1.1" 404 6603 "https://dashboard.heroku.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 2023-07-02T08:25:19.457824+00:00 heroku[router]: at=info method=GET path="/" host=masatweet-aaf0417ae442.herokuapp.com request_id=ab4fe904-2522-4113-8ebc-914a07ad7680 fwd="60.149.177.175" dyno=web.1 connect=1ms service=141ms status=404 bytes=6816 protocol=https 2023-07-02T08:25:19.785126+00:00 app[web.1]: 10.1.30.231 - - [02/Jul/2023:08:25:19 +0000] "GET /favicon.ico HTTP/1.1" 200 - "https://masatweet-aaf0417ae442.herokuapp.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 2023-07-02T08:25:19.787804+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=masatweet-aaf0417ae442.herokuapp.com request_id=64452317-569e-418f-848c-f4f4d5d74492 fwd="60.149.177.175" dyno=web.1 connect=0ms service=1ms status=200 bytes=231 protocol=https
githubのユニット・フィーチャーテストのところにもエラーが表示されてしまう。
該当のソースコード
routes\web.php
php
1<?php 2 3use App\Http\Controllers\ProfileController; 4use Illuminate\Support\Facades\Route; 5 6/* 7|-------------------------------------------------------------------------- 8| Web Routes 9|-------------------------------------------------------------------------- 10| 11| Here is where you can register web routes for your application. These 12| routes are loaded by the RouteServiceProvider and all of them will 13| be assigned to the "web" middleware group. Make something great! 14| 15*/ 16 17Route::get('/', function () { 18 return view('welcome'); 19}); 20 21// Sample 22Route::get('/sample', [\App\Http\Controllers\Sample\IndexController::class,'show']); 23Route::get('/sample/{id}', [\App\Http\Controllers\Sample\IndexController::class,'showId']); 24 25 26// Tweet 27Route::middleware('auth')->group(function () { 28 Route::post('/tweet/create', \App\Http\Controllers\Tweet\CreateController::class) 29 ->name('tweet.create'); 30 Route::get('/tweet/update/{tweetId}', \App\Http\Controllers\Tweet\Update\IndexController::class) 31 ->name('tweet.update.index'); 32 Route::put('/tweet/update/{tweetId}', \App\Http\Controllers\Tweet\Update\PutController::class) 33 ->name('tweet.update.put'); 34 Route::delete('/tweet/delete/{tweetId}', \App\Http\Controllers\Tweet\DeleteController::class) 35 ->name('tweet.delete'); 36}); 37Route::get('/tweet', \App\Http\Controllers\Tweet\IndexController::class) 38->name('tweet.index'); 39 40 41Route::get('/dashboard', function () { 42 return view('dashboard'); 43})->middleware(['auth', 'verified'])->name('dashboard'); 44 45Route::middleware('auth')->group(function () { 46 Route::get('/profile', [ProfileController::class, 'edit'])->name('profile.edit'); 47 Route::patch('/profile', [ProfileController::class, 'update'])->name('profile.update'); 48 Route::delete('/profile', [ProfileController::class, 'destroy'])->name('profile.destroy'); 49}); 50 51require __DIR__.'/auth.php'; 52
.github\workflows\phpunit.yml
yml
1name: Laravel 2 3on: 4 push: 5 pull_request: 6 7env: 8 DB_USERNAME: sail 9 DB_PASSWORD: password 10 MAIL_FROM_ADDRESS: info@example.com 11 12jobs: 13 phpunit: 14 15 runs-on: ubuntu-latest 16 17 services: 18 mysql.test: 19 image: 'mysql/mysql-server:8.0' 20 ports: 21 - 3306:3306 22 env: 23 MYSQL_DATABASE: 'example_app' 24 MYSQL_USER: ${{ env.DB_USERNAME }} 25 MYSQL_PASSWORD: ${{ env.DB_PASSWORD }} 26 MYSQL_ALLOW_EMPTY_PASSWORD: 1 27 options: >- 28 --health-cmd "mysqladmin ping" 29 --health-interval 10s 30 --health-timeout 5s 31 --health-retries 5 32 33 steps: 34 - uses: actions/checkout@v2 35 - name: Setup PHP 36 uses: shivammathur/setup-php@v2 37 with: 38 php-version: '8.1' 39 tools: composer:v2 40 - name: Copy .env 41 run: cp .env.example .env.testing 42 - name: Install Dependencies 43 if: steps.cache.outputs.cache-hit != 'true' 44 run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist 45 - name: Generate key 46 run: php artisan key:generate --env testing 47 - name: Set hostname 48 run: sudo echo "127.0.0.1 mysql.test" | sudo tee -a /etc/hosts 49 - name: Execute tests (Unit and Feature tests) via PHPUnit 50 run: vendor/bin/phpunit
package.json
json
1{ 2 "private": true, 3 "type": "module", 4 "scripts": { 5 "dev": "vite", 6 "build": "vite build", 7 "serve": "vite preview" 8 }, 9 "devDependencies": { 10 "@popperjs/core": "^2.11.6", 11 "@tailwindcss/forms": "^0.5.2", 12 "@vitejs/plugin-react": "^4.0.1", 13 "@vitejs/plugin-vue": "^4.2.3", 14 "alpinejs": "^3.4.2", 15 "autoprefixer": "^10.4.2", 16 "axios": "^1.1.2", 17 "bootstrap": "^5.2.3", 18 "laravel-vite-plugin": "^0.7.8", 19 "lodash": "^4.17.19", 20 "postcss": "^8.4.6", 21 "sass": "^1.56.1", 22 "tailwindcss": "^3.1.0", 23 "vite": "^4.3.9" 24 } 25} 26
vite.config.js
javascript
1import { defineConfig } from 'vite'; 2import laravel from 'laravel-vite-plugin'; 3 4export default defineConfig({ 5 plugins: [ 6 laravel({ 7 input: [ 8 'resources/css/app.css', 9 'resources/js/app.js', 10 ], 11 refresh: true, 12 }), 13 ], 14 server: { 15 hmr: { 16 host: 'localhost', 17 }, 18 }, 19});
試したこと
・ユニット・フィーチャーテストのファイルを削除した(削除済み)
・vite.config.jsのserver: {・・・}の部分を削除してデプロイしてみた(戻した)
他に試してほしいこと、参照したいファイルなどがございましたらコメントで教えてください。
補足情報(FW/ツールのバージョンなど)
Laravel Framework 10.13.5
VITE v4.3.9

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。