I created the subdomain routing api.service.dev under Laravel. I used passport
for authentication and enabled CreateFreshApiToken
.
service.dev, and when requesting https://api.service.dev/user
, it prompts 401 Unauthenticated.
Check that the request header does not contain the laravel_token created by CreateFreshApiToken
This cookie
May I ask how to solve this problem?
世界只因有你2017-05-16 16:49:15
For the installation method, please go to https://github.com/barryvdh/l...
return [
/*
|--------------------------------------------------------------------------
| Laravel CORS
|--------------------------------------------------------------------------
|
| allowedOrigins, allowedHeaders and allowedMethods can be set to array('*')
| to accept any value.
|
*/
'supportsCredentials' => true,
'allowedOrigins' => ['*'],
'allowedHeaders' => ['*'],
'allowedMethods' => ['*'],
'exposedHeaders' => [],
'maxAge' => 0,
];
Add SESSION_DOMAIN=.xxx.com
in the .env file. This is service.dev, so .service.dev should be filled in, so that all subdomains of service.dev can share cookies
Add the following code to bootstrap.js
window.axios.defaults.withCredentials = true;
In this way, you can access the cross-domain API normally! ! !
过去多啦不再A梦2017-05-16 16:49:15
Axios has no problem under chrome after configuring withCredentials = true.
But under IE, the server side also needs to configure the P3P response header. . . IE is so unique