dmytroshved's avatar

Laravel: Configure Trusted Hosts

Hello, I am struggling with configuring my trustedHosts middleware inside bootstrap/app.php

How can I properly configure it?

The docs don't describe how to understand what domain names are needed

And also, should I configure trusted hosts if I'll use DigitalOcean & Forge to deploy my project

Would be grateful for your help

Best regards

0 likes
3 replies
Glukinho's avatar

Do you have some custom configuration? Or something doesn't work as it should?

In simple typical configuration, where you have a web server like nginx which handles http connections and host names your app is accessible by, you don't need to set the trustHosts setting at all.

1 like
dmytroshved's avatar

No, I don't have custom configurations, I don't use nginx, now I am using Wampserver for local development.

Thanks

Glukinho's avatar
Level 31

For local development you surely don't need to touch that setting.

When it comes to releasing to production, you most likely will not need it too.

You need it when a web server is out of your control and you don't want your app to respond to something like https://12.34.56.78 (public IP address of your server).

Please or to participate in this conversation.