Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
孙龙
/
note-library
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
4362d872
authored
Feb 20, 2023
by
孙龙
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
js跨域
parent
a5fd8743
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
1 additions
and
8 deletions
app/Http/Middleware/CrossHttp.php
app/Http/routes.php
app/Http/Middleware/CrossHttp.php
View file @
4362d872
...
...
@@ -13,17 +13,11 @@ class CrossHttp
public
function
handle
(
$request
,
Closure
$next
)
{
$response
=
$next
(
$request
);
$origin
=
$request
->
server
(
'HTTP_ORIGIN'
)
?
$request
->
server
(
'HTTP_ORIGIN'
)
:
''
;
$allow_origin
=
[
'http://localhost:3000'
,
];
// if (in_array($origin, $allow_origin)) {
$response
->
header
(
'Access-Control-Allow-Origin'
,
"*"
);
$response
->
header
(
'Access-Control-Allow-Headers'
,
'Origin, Content-Type, Cookie,X-Requested-With, X-CSRF-TOKEN, Accept, Authorization, X-XSRF-TOKEN'
);
$response
->
header
(
'Access-Control-Expose-Headers'
,
'Authorization, authenticated'
);
$response
->
header
(
'Access-Control-Allow-Methods'
,
'GET, POST, PATCH, PUT, OPTIONS'
);
$response
->
header
(
'Access-Control-Allow-Credentials'
,
'true'
);
// }
return
$response
;
}
}
\ No newline at end of file
app/Http/routes.php
View file @
4362d872
...
...
@@ -28,7 +28,7 @@ Route::pattern('roleId', '[0-9]+');
|
*/
Route
::
group
([
'middleware'
=>
'cors'
],
function
()
{
Route
::
group
([
'middleware'
=>
[
"cors"
]
],
function
()
{
Route
::
get
(
'/api/get_user_labels'
,
'ApiController@getUserLabels'
);
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment