Laravel 5.7-开发和生产服务器上的不同cookie

时间:2019-01-15 18:03:38

标签: laravel laravel-5.7

我设置的Laravel应用程序在我的CentoS 7开发服务器上可以正常工作。具体来说:使用以下方法登录和注销:

2019-01-15T17:48:42.496Z    cafaa35a-18ed-11e9-9e84-ad156518dcbe    { UnknownError: Forbidden
at Object.extractError (/var/task/node_modules/aws-sdk/lib/protocol/json.js:51:27)
at Request.extractError (/var/task/node_modules/aws-sdk/lib/protocol/rest_json.js:52:8)
at Request.callListeners (/var/task/node_modules/aws-sdk/lib/sequential_executor.js:106:20)
at Request.emit (/var/task/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
at Request.emit (/var/task/node_modules/aws-sdk/lib/request.js:683:14)
at Request.transition (/var/task/node_modules/aws-sdk/lib/request.js:22:10)
at AcceptorStateMachine.runTo (/var/task/node_modules/aws-sdk/lib/state_machine.js:14:12)
at /var/task/node_modules/aws-sdk/lib/state_machine.js:26:10
at Request.<anonymous> (/var/task/node_modules/aws-sdk/lib/request.js:38:9)
at Request.<anonymous> (/var/task/node_modules/aws-sdk/lib/request.js:685:12)
message: 'Forbidden',
code: 'UnknownError',
statusCode: 403,
time: 2019-01-15T17:48:42.440Z,
requestId: 'XXXX',
retryable: false,
retryDelay: 1.6256019461018845 }


2019-01-15T17:48:42.938Z    cafaa35a-18ed-11e9-9e84-ad156518dcbe    Error: 
2019-01-15T17:48:42.938Z    cafaa35a-18ed-11e9-9e84-ad156518dcbe    { QuickSightUserNotFoundException: Could not find user information in QuickSight
at Object.extractError (/var/task/node_modules/aws-sdk/lib/protocol/json.js:51:27)
at Request.extractError (/var/task/node_modules/aws-sdk/lib/protocol/rest_json.js:52:8)
at Request.callListeners (/var/task/node_modules/aws-sdk/lib/sequential_executor.js:106:20)
at Request.emit (/var/task/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
at Request.emit (/var/task/node_modules/aws-sdk/lib/request.js:683:14)
at Request.transition (/var/task/node_modules/aws-sdk/lib/request.js:22:10)
at AcceptorStateMachine.runTo (/var/task/node_modules/aws-sdk/lib/state_machine.js:14:12)
at /var/task/node_modules/aws-sdk/lib/state_machine.js:26:10
at Request.<anonymous> (/var/task/node_modules/aws-sdk/lib/request.js:38:9)
at Request.<anonymous> (/var/task/node_modules/aws-sdk/lib/request.js:685:12)
message: 'Could not find user information in QuickSight',
code: 'QuickSightUserNotFoundException',
time: 2019-01-15T17:48:42.938Z,
requestId: 'XXXXX,
statusCode: 412,
retryable: false,
retryDelay: 84.05706341238961 }

但是,当我将其移至实时服务器时,“注销”功能将停止工作。我单击Chrome中的注销按钮

    php artisan make:auth

它通过我的LoginController函数重定向到我的登录屏幕,

    <form id="logout-form" action="{{ route('logout') }}" method="POST" style="display: none;">
    @csrf
    </form>

,但是当我输入应该是安全的URL时,该URL就会加载。如果我刷新页面,然后实际上会将我注销。

在Firefox中,当单击刀片上的注销按钮时,什么也没有发生。

此外,可能值得注意的是,在我的开发服务器上的Chrome中,为页面设置的Cookie的从现在(今天)开始的Expires / Max-Age为2小时

    public function logout(Request $request) {
        Auth::logout();
        return redirect('/login');
    }

这是正确的。

在我的实时服务器上的Chrome中,cookie的Expires / Max-Age是

    2019-01-15.... 

除了我的APP_URL,数据库凭据和邮件服务器外,我的.env文件是相同的。我什么都没改变-仅上传文件。该网站上的其余功能都很完美。

我尝试了许多不同的配置和搜索,但还是没有运气。谢谢您阅读本文。

1 个答案:

答案 0 :(得分:0)

原来是在我的实时服务器上的.htaccess文件中,我正在修改Cache-Control设置:

    <IfModule mod_headers.c>
        <FilesMatch ".(php)$">
            Header set Cache-Control "max-age=86400"
        </FilesMatch>
    </IfModule>

一旦我删除了这些行,我的Laravel应用就可以正常工作了。