首页 > 解决方案 > 为什么我的应用可以在本地运行,但不能在 Heroku 上运行?

问题描述

我正在用 Symfony 和 MySQL 做一个应用程序。一切都在本地工作,但是当我想用 Heroku 部署它时遇到问题。我在日志中出现错误 500 并显示此消息:

2021-10-19T07:50:08.112271+00:00 app[web.1]: 10.1.25.112 - - [19/Oct/2021:07:50:08 +0000] "GET /mon-compte/mes-emprunts HTTP/1.1" 500 3208 "https://agile-reaches-89145.herokuapp.com/mon-compte" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.81 Safari/537.36   
2021-10-19T07:50:08.112595+00:00 app[web.1]: {"message":"Stored the security token in the session.","context":{"key":"_security_main"},"level":100,"level_name":"DEBUG","channel":"security","datetime":"2021-10-19T07:50:08.108221+00:00","extra":{}}

我看到问题出在令牌和会话上。但我不知道这意味着什么。

这是我的 .env

# In all environments, the following files are loaded if they exist,
# the latter taking precedence over the former:
#
#  * .env                contains default values for the environment variables needed by the app
#  * .env.local          uncommitted file with local overrides
#  * .env.$APP_ENV       committed environment-specific defaults
#  * .env.$APP_ENV.local uncommitted environment-specific overrides
#
# Real environment variables win over .env files.
#
# DO NOT DEFINE PRODUCTION SECRETS IN THIS FILE NOR IN ANY OTHER COMMITTED FILES.
#
# Run "composer dump-env prod" to compile .env files for production use (requires symfony/flex >=1.2).
# https://symfony.com/doc/current/best_practices.html#use-environment-variables-for-infrastructure-configuration

###> symfony/framework-bundle ###
APP_ENV=dev
APP_SECRET=8f463379d965345950d4de046c122da9
###< symfony/framework-bundle ###

###> symfony/mailer ###
# MAILER_DSN=smtp://localhost
###< symfony/mailer ###

###> doctrine/doctrine-bundle ###
# Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml
#
# DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db"
DATABASE_URL="mysql://root:@127.0.0.1:3306/mybibliotheque?mysql-10.4.20"
#DATABASE_URL="postgresql://db_user:db_password@127.0.0.1:5432/db_name?serverVersion=13&charset=utf8"
###< doctrine/doctrine-bundle ###

我该如何解决这个问题?谢谢

标签: symfonyherokutoken

解决方案


推荐阅读