Laravel 5.6签名的URL在APP_ENV = production中不起作用

Dan*_*Dan 1 laravel laravel-5.6

我设置了两条路线

Route::get('/bugreport', 'SomeController@create')
    ->middleware('signed')
    ->name('bugreport');

Route::get('/getlink', function() {
    return dd(\URL::signedRoute('bugreport', ['data' => 3]));
});
Run Code Online (Sandbox Code Playgroud)

APP_ENV=local我可以访问时,请/getlink点击生成的URL并显示它。当APP_ENV=production(更改变量时实际物理环境未更改)时,此命令不再起作用...说明无效签名。有什么建议么?

更新:

我们确实有...可能是其中一部分

class AppServiceProvider extends ServiceProvider
{
/**
 * Bootstrap any application services.
 *
 * @return void
 */
public function boot()
{
    if (!config('app.is_local')) {
        URL::forceScheme('https');
    }
}
Run Code Online (Sandbox Code Playgroud)

注意:删除上面的代码实际上可以解决此问题,但随后会中断登录等操作,因此需要了解原因,否则这不是选项:(。

更新更新:

环境是heroku,.htaccess具有(根据https://help.heroku.com/J2R1S4T8/can-heroku-force-an-application-to-use-ssl-tls

#### FORCE SSL
## see - https://help.heroku.com/J2R1S4T8/can-heroku-force-an-application-to-use-ssl-tls
RewriteCond %{HTTP_HOST} !=localhost
# If we receive a forwarded http request from a proxy...
RewriteCond %{HTTP:X-Forwarded-Proto} =http [OR]

# ...or just a plain old http request directly from the client
RewriteCond %{HTTP:X-Forwarded-Proto} =""
RewriteCond %{HTTPS} !=on

# Redirect to https version
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
### End Force SSL
Run Code Online (Sandbox Code Playgroud)

naa*_*ter 7

我有一个类似的问题-如果您使用TrustedProxy中间件,则可以很容易地解决。

如果您在负载均衡器后面的Heroku或AWS上,并且已将SSL卸载到负载均衡器,则可能需要信任所有代理,以便Laravel的请求可以检测到您实际上在SSL连接上。然后,签名URL验证将起作用。

您可以在此处查看doku:
Laravel 5.7 https://laravel.com/docs/5.7/requests#configuring-trusted-proxies
Laravel 5.6 https://laravel.com/docs/5.6/requests#configuring-trusted-proxies