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?
1. Install barryvdh/laravel-cors
For the installation method, please go to https://github.com/barryvdh/l...
2. Configure cors.php
3. Configure the domain of the session
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 cookies4. Finally configure the front-end request
Add the following code to
bootstrap.js
In this way, you can access the cross-domain API normally! ! !
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