kata_1997
@kata_1997 (mu7kata)

Are you sure you want to delete the question?

If your question is resolved, you may close it.

Leaving a resolved question undeleted may help others!

We hope you find it useful!

Heroku でデプロイ後404エラーがでてしまいます。。

解決したいこと

デプロイしたwebアプリのエラー解決。

概要

学習管理アプリを作成し、Herokuへデプロイ。
本番環境で学習内容編集ページへ遷移、再登録しようすると404エラーが発生してしまいます。ローカル環境では問題なく処理できるのですが、本番環境だとエラーがでてうまくいきません。。

デプロイまでは下記の手順でおこなっております。
https://qiita.com/kata_kata_1997/questions/0a5b05dfea30b4bcb207

エラー内容

スクリーンショット 2020-10-06 13.59.06.png

スクリーンショット 2020-10-06 13.52.32.png

↓Application Logsの拡大

2020-10-06T04:51:50.967886+00:00 heroku[router]: at=info method=POST path="/Edit_study.php" host=munakatatest8.herokuapp.com request_id=8e3756a5-4714-4271-b932-88d79f1306c6 fwd="1.75.231.68" dyno=web.1 connect=1ms service=282ms status=302 bytes=12375 protocol=https
2020-10-06T04:51:50.968087+00:00 app[web.1]: 10.69.229.158 - - [06/Oct/2020:04:51:50 +0000] "POST /Edit_study.php HTTP/1.1" 302 11995 "https://munakatatest8.herokuapp.com/Edit_study.php" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36
2020-10-06T04:51:51.213424+00:00 app[web.1]: 10.69.229.158 - - [06/Oct/2020:04:51:51 +0000] "GET /Readback.php HTTP/1.1" 404 196 "https://munakatatest8.herokuapp.com/Edit_study.php" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36
2020-10-06T04:51:51.213416+00:00 heroku[router]: at=info method=GET path="/Readback.php" host=munakatatest8.herokuapp.com request_id=2bcd101c-0660-4fb0-baec-536961f88f63 fwd="1.75.231.68" dyno=web.1 connect=1ms service=2ms status=404 bytes=360 protocol=https

 環境

【言語】
  PHP 7.3.9
 【DBMS】
  MySQL 5.7.26
 【フレームワーク】
  なし
 【開発環境】
  MacOS Catalina 10.15.5
 【バージョン管理】
  Git 2.24.3
【本番環境】
Heroku

gitHeroku push masterの結果↓

ApplenoMacBook-Air:deploytest2 ymunakata$ git push heroku master
Enumerating objects: 7, done.
Counting objects: 100% (7/7), done.
Delta compression using up to 4 threads
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 424 bytes | 424.00 KiB/s, done.
Total 4 (delta 2), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> PHP app detected
remote: -----> Bootstrapping...
remote: 
remote:  !     WARNING: Your 'composer.lock' is out of date!
remote:  !     
remote:  !     The 'composer.lock' file in your project is not up to date with
remote:  !     the main 'composer.json' file. This may result in installation
remote:  !     of incorrect packages or package versions.
remote:  !     
remote:  !     The lock file is required in order to guarantee reliable and
remote:  !     reproducible installation of dependencies across systems and
remote:  !     deploys. It must always be kept in sync with 'composer.json'.
remote:  !     
remote:  !     Whenever you change 'composer.json', ensure that you perform
remote:  !     the following steps locally on your computer:
remote:  !     1) run 'composer update'
remote:  !     2) add all changes using 'git add composer.json composer.lock'
remote:  !     3) commit using 'git commit'
remote:  !     
remote:  !     Ensure that you updated the lock file correctly, and that you
remote:  !     ran 'git add' on both files, before deploying again.
remote:  !     
remote:  !     Please remember to always keep your 'composer.lock' updated in
remote:  !     lockstep with 'composer.json' to avoid common problems related
remote:  !     to dependencies during collaboration and deployment.
remote:  !     
remote:  !     Please refer to the Composer documentation for further details:
remote:  !     https://getcomposer.org/doc/
remote:  !     https://getcomposer.org/doc/01-basic-usage.md
remote: 
remote: -----> Installing platform packages...
remote:        - php (7.3.23)
remote:        - ext-mbstring (bundled with php)
remote:        - apache (2.4.46)
remote:        - nginx (1.18.0)
remote: 
remote:  !     WARNING: Your app's PHP version is close to end of maintenance
remote:  !     
remote:  !     Only security updates will be provided for your PHP version
remote:  !     series by the PHP Group as of 2020-12-06.
remote:  !     
remote:  !     It is strongly recommended you update your app to a version of
remote:  !     PHP with "active support" status immediately to ensure you get
remote:  !     the latest bugfixes and security updates each time you deploy.
remote:  !     
remote:  !     You may check the list of versions supported by the PHP Group
remote:  !     and their EOL dates here: http://php.net/supported-versions.php
remote:  !     
remote:  !     For a list of supported runtimes & extensions on Heroku, please
remote:  !     refer to: https://devcenter.heroku.com/articles/php-support
remote: 
remote: -----> Installing dependencies...
remote:        Composer version 1.10.13 2020-09-09 11:46:34
remote: 
remote:  !     WARNING: Composer vendor dir found in project!
remote:  !     
remote:  !     Your Git repository contains Composer's 'vendor' directory.
remote:  !     
remote:  !     This directory should not be under version control; only your
remote:  !     'composer.json' and 'composer.lock' files need to be added, as
remote:  !     Composer will handle installation of dependencies on deploy.
remote:  !     
remote:  !     To suppress this notice, first remove the folder from the index
remote:  !     by running 'git rm -r --cached vendor/'.
remote:  !     Next, edit your project's '.gitignore' file and add the folder
remote:  !     '/vendor/' to the list, then commit the changes.
remote:  !     
remote:  !     For more info, refer to the Composer FAQ: http://bit.ly/1rlCSZU
remote: 
remote:        Loading composer repositories with package information
remote:        Installing dependencies from lock file
remote:        Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. It is recommended that you run `composer update` or `composer update <package name>`.
remote:        Nothing to install or update
remote:        Generating optimized autoload files
remote: -----> Preparing runtime environment...
remote:        NOTICE: No Procfile, using 'web: heroku-php-apache2'.
remote: -----> Checking for additional extensions to install...
remote: -----> Discovering process types
remote:        Procfile declares types -> web
remote: 
remote: -----> Compressing...
remote:        Done: 14.8M
remote: -----> Launching...
remote:        Released v9
remote:        https://munakatatest8.herokuapp.com/ deployed to Heroku
remote: 
remote: Verifying deploy... done.
To https://git.heroku.com/munakatatest8.git
   99381dc..345043a  master -> master

やったこと

ログを確認したところ、GET処理の際にエラーが発生してしまっていると推測しましたが、どのコードをどう修正していいかわからず、つまづいております。

解決法の分かるかたいらっしゃいましたらご教示いただけると大変助かります。
よろしくお願いします。

0

1Answer

/ReadBack.php はアクセスできていて /Readback.php は404になってますね。 遷移するコードを直して大文字小文字を正しくしてください。

ローカルでだけ動くのはファイルシステムの違いに起因すると思います。 macOS のデフォルトのファイルシステムはファイル名の大文字小文字を区別しませんが、 Linux のファイルシステムでは大抵区別するようになっています。

0Like

Comments

  1. @kata_1997

    Questioner

    コードの大文字小文字のコードを修正したところ、正しく処理されるようになりました。
    度々ありがとうございます。助かりました。。

Your answer might help someone💌