FrontEndにReact, BackEndにLaravelを使用したApplicationを作成後、
Heroku上にDeployしstatus=200をLog内で確認までは出来たんですが
肝心のViewが表示出来てません。
DBの設定はまだですが同じ条件(同じ資源)でPostgresをHerokuのDoc通り設定しそちらを設定後も表示には反映されていないので影響はないと思われます。
RoutingはReact-Routerで以下の様に設定し
index.js
import React from 'react'; import ReactDOM from 'react-dom'; import { BrowserRouter as Router, Switch, Route } from 'react-router-dom'; import PrivateRoute from './Auth/PrivateRoute'; import PublicRoute from './Auth/PublicRoute'; import Login from '../js/Auth/Login'; import SignUp from '../js/Auth/SignUp'; import Main from '../js/Pages/Main'; import Search from '../js/Search/Search'; import NewDiary from './NewDiary/NewDiary'; import ListDiary from './ListDiary/ListDiary'; import EditDiary from './ListDiary/EditDiary'; function Index() { const Top = () => { return( <div> <Main /> </div> ) } return ( <Router> <Switch> <PublicRoute exact path="/" component={Top} /> <PublicRoute resricted={false} path="/login" component={Login} /> <PublicRoute resricted={true} path="/sign_up" component={SignUp} /> <PrivateRoute path="/search" component={Search} /> <PrivateRoute path="/new_diary" component={NewDiary} /> <PrivateRoute path="/list_diary" component={ListDiary} /> <PrivateRoute path="/:id" component={EditDiary} /> </Switch> </Router> ); }
Main.js
import React, { useState } from 'react'; import { Redirect } from 'react-router-dom'; import Login from '../Auth/Login'; import SignUp from '../Auth/SignUp'; const Main = () => { const data = localStorage.getItem('isLoggedIn'); console.log(localStorage) return ( <div className="py-4"> <div className="container"> <div className="row justify-content-center"> <div className="col-md-8"> { !data ? <Redirect to="/login" /> : <Redirect to="search" /> } </div> </div> </div> </div> ); }
Web.php上は以下の様に設定しています```Route::view('/{path?}', 'app');``
herokuのログは以下です
2021-01-28T08:10:59.588111+00:00 heroku[web.1]: Stopping all processes with SIGTERM 2021-01-28T08:10:59.625428+00:00 app[web.1]: SIGTERM received, attempting graceful shutdown... 2021-01-28T08:10:59.626560+00:00 app[web.1]: Stopping php-fpm... 2021-01-28T08:10:59.628554+00:00 app[web.1]: Stopping httpd gracefully... 2021-01-28T08:10:59.629059+00:00 app[web.1]: Stopping httpd... 2021-01-28T08:10:59.663445+00:00 app[web.1]: Shutdown complete. 2021-01-28T08:10:59.724409+00:00 heroku[web.1]: Process exited with status 143 2021-01-28T08:11:00.141447+00:00 heroku[web.1]: Starting process with command `vendor/bin/heroku-php-apache2 public/` 2021-01-28T08:11:03.392811+00:00 app[web.1]: DOCUMENT_ROOT changed to 'public/' 2021-01-28T08:11:03.461539+00:00 app[web.1]: Detected 536870912 Bytes of RAM 2021-01-28T08:11:03.487622+00:00 app[web.1]: PHP memory_limit is 128M Bytes 2021-01-28T08:11:03.494917+00:00 app[web.1]: Starting php-fpm with 4 workers... 2021-01-28T08:11:03.575553+00:00 app[web.1]: Starting httpd... 2021-01-28T08:11:04.128533+00:00 heroku[web.1]: State changed from starting to up 2021-01-28T08:12:47.689607+00:00 heroku[router]: at=info method=GET path="/" host=whispering-temple-30215.herokuapp.com request_id=7fc3b3ea-f393-4329-81b8-d27f1ee667b2 fwd="58.183.124.2" dyno=web.1 connect=0ms service=282ms status=200 bytes=5805 protocol=https 2021-01-28T08:12:47.689145+00:00 app[web.1]: 10.9.247.118 - - [28/Jan/2021:08:12:47 +0000] "GET / HTTP/1.1" 200 4724 "https://dashboard.heroku.com/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.96 Safari/537.36 2021-01-28T08:12:57.722295+00:00 heroku[router]: at=info method=GET path="/" host=whispering-temple-30215.herokuapp.com request_id=dfeea888-f0a8-4fef-8c21-f9dfb9040107 fwd="58.183.124.2" dyno=web.1 connect=0ms service=23ms status=200 bytes=5805 protocol=https 2021-01-28T08:12:57.891198+00:00 heroku[router]: at=info method=GET path="/" host=whispering-temple-30215.herokuapp.com request_id=acb6a054-f914-4728-a4c3-573699a1cbfe fwd="58.183.124.2" dyno=web.1 connect=1ms service=18ms status=200 bytes=5805 protocol=https
HerokuのDoc(https://devcenter.heroku.com/articles/getting-started-with-laravel)に沿って設定を行いました。
Procfileweb: vendor/bin/heroku-php-apache2 public/
APP_KEYの設定も行ってます。
Folderの構成は以下です
もし、この様なケースの対して有識のある方がいらっしゃいましたらご教授頂けると大変ありがたいです。
あなたの回答
tips
プレビュー