Untrusted host while running with url different than localhost
See original GitHub issueEnvironment
- Docker for Mac 18.06.1-ce-mac73
- macOS High Sierra
Steps to reproduce
- Install API Platform as described here: https://api-platform.com/docs/distribution#installing-the-framework (download package & run
docker-compose up -d) - Open
https://localhostin browser. It works. - (problem starts here) Add
127.0.0.1 myproject.devto/etc/hosts Edit(not required nowadays, 2019-07-03, kniziol)src/Welcome.jsand replacelocalhostwithmyproject.dev- Open
http://myproject.devin browser. It works. - Click any link in first/left box of
AVAILABLE SERVICESsection (APIorCACHED API) - You will see the
Untrusted hostexception:
- Open
api/.env - Add
myproject.devtoTRUSTED_HOSTS(before:localhost,api, after:localhost,api,myproject.dev) - Go to step
6. Doesn’t work. - Clear cache & restart all containers by running
docker-compose exec php bin/console c:c && docker-compose restart. Doesn’t work. - In
api/public/index.php:31value of$_SERVER['TRUSTED_HOSTS']is stilllocalhost,api, but it should belocalhost,api,myproject.dev.
Solution
- Open
api/config/packages/framework.yaml - Add
framework.trusted_hostsparameter:
framework:
secret: '%env(APP_SECRET)%'
trusted_hosts:
- localhost
- api
- myproject.dev
- Click any link in first/left box of
AVAILABLE SERVICESsection (APIorCACHED API) - It works.
Problem
Host added to TRUSTED_HOSTS is not included.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:4
- Comments:8 (2 by maintainers)
Top Results From Across the Web
Untrusted Host "localhost" in [duplicate] - Drupal Answers
I have an Apache web server running locally, with the test site defined using a VirtualHost directive. I add the domain name of...
Read more >docker container running on untrusted host machine
I know that docker containers which are running on a host machine have root privileges. This is mostly incorrect. A docker container has ......
Read more >Untrusted Host "127.0.0.1
When I run symfony server:start it returns Error like "Untrusted Host ... Use localhost when accessing website or add 127.0.0.1 to trusted hosts:...
Read more >Troubleshooting Apache SSL Certificate Errors
How to correct common SSL Certificate errors with Apache Servers. Read more about troubleshooting Apache SSL Certificate errors.
Read more >Security in the Jupyter notebook server - Read the Docs
Since access to the Jupyter notebook server means access to running arbitrary code, ... When token authentication is enabled, the notebook uses a...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Solution
Domains should be separated by
|(not by,).Incorrect
Correct
@teohhanhui @dunglas Problem solved. Thanks.
@ghanbari Sorry, doesn’t work