Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Tenzing
/
pdf-customizer
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
98efbb3f
authored
2016-05-12 15:35:09 -0400
by
Jeff Balicki
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
f
1 parent
a36994a8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
27 deletions
app/Http/Middleware/Cors.php
app/Http/Middleware/Cors.php
View file @
98efbb3
<?php
use
Closu
re
;
namespace
App\Http\Middlewa
re
;
class
CORS
{
use
Closure
;
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
class
Cors
{
public
function
handle
(
$request
,
Closure
$next
)
{
header
(
"Access-Control-Allow-Origin: *"
);
// ALLOW OPTIONS METHOD
$headers
=
[
'Access-Control-Allow-Methods'
=>
'POST, GET, OPTIONS, PUT, DELETE'
,
'Access-Control-Allow-Headers'
=>
'Content-Type, X-Auth-Token, Origin'
];
if
(
$request
->
getMethod
()
==
"OPTIONS"
)
{
// The client-side application can set only headers allowed in Access-Control-Allow-Headers
return
Response
::
make
(
'OK'
,
200
,
$headers
);
}
$response
=
$next
(
$request
);
foreach
(
$headers
as
$key
=>
$value
)
$response
->
header
(
$key
,
$value
);
return
$response
;
return
$next
(
$request
)
->
header
(
'Access-Control-Allow-Origin'
,
'*'
)
->
header
(
'Access-Control-Allow-Methods'
,
'GET, POST, PUT, DELETE, OPTIONS'
);
}
}
\ No newline at end of file
...
...
Please
register
or
sign in
to post a comment