laravel / octane

Supercharge your Laravel application's performance.
https://laravel.com/docs/octane
MIT License
3.73k stars 289 forks source link

Invalid signature error with temporary signed routes #866

Closed dasundev closed 4 months ago

dasundev commented 4 months ago

Octane Version

2.3.3

Laravel Version

10.45.1

PHP Version

8.2.15

What server type are you using?

FrankenPHP

Server Version

1.0.2

Database Driver & Version

No response

Description

When I create a temporary signed route URL for a named route, it only works in the local environment. In production, it always returns a 403 page.

Steps To Reproduce

Create a temporary signed route URL:

use Illuminate\Support\Facades\URL;

$url = URL::temporarySignedRoute(
    'example', now()->addMinutes(30), ['email' => 'foo@test.com']
);

echo $url;

To use this URL, simply visit it in your browser.

dasundev commented 4 months ago

I have been able to troubleshoot the problem.

There were additional request headers in my Nginx configuration. Only the following request headers are enough to work everything smoothly:

proxy_set_header Host $http_host;
proxy_set_header Scheme $scheme;
proxy_set_header SERVER_PORT $server_port;
proxy_set_header REMOTE_ADDR $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;

Also, make sure you have updated the trusted proxies in the application.

// Example: Trusting all proxies
protected $proxies = '*';

For more information, please refer to this documentation.