react-routerを使用しているのですが、
1 http://localhost:3000/about/ (npm startしたサイト)
2 http://example.local/about/ (npm run buildしたサイト)
にそれぞれアクセスした時に、2の時は404 not foundとなり、
http://example.local/を経由しないと表示できません。
この挙動から憶測すると、npm startの時はサーバーサイドレンダリングが効いているのか?
と思うのですが、いまいちよくわかりません。
npm startの時と、npm run buildの時でサイトに違いがあるのでしょうか?
package.jsonの内容です。
package.json
1{ 2 "name": "examplelocal", 3 "version": "0.1.0", 4 "private": true, 5 "dependencies": { 6 "moment": "^2.19.2", 7 "react": "^16.1.1", 8 "react-bootstrap": "^0.31.5", 9 "react-datetime": "^2.11.0", 10 "react-dom": "^16.1.1", 11 "react-router-dom": "^4.2.2", 12 "react-scripts": "1.0.17" 13 }, 14 "scripts": { 15 "start": "react-scripts start", 16 "build": "react-scripts build", 17 "test": "react-scripts test --env=jsdom", 18 "eject": "react-scripts eject" 19 } 20}
example.localはローカルのnginxでアクセスしています。
example.local.conf
1server { 2 listen 80; 3 server_name example.local; 4 root /home/examplelocal/examplelocal/build/; 5 index index.php index.html index.htm; 6 client_max_body_size 99M; 7 server_tokens off; 8 9 location ~ .php$ { 10 fastcgi_pass 127.0.0.1:9000; 11 fastcgi_index index.php; 12 fastcgi_param SCRIPT_FILENAME /home/examplelocal/examplelocal/build$fastcgi_script_name; 13 include fastcgi_params; 14 } 15} 16 17
回答1件
あなたの回答
tips
プレビュー