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
681557b5
authored
2016-05-12 14:57:39 -0400
by
Jeff Balicki
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
w
1 parent
d0e22954
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
15 deletions
app/Http/Middleware/Cors.php
app/Http/routes.php
bootstrap/app.php
app/Http/Middleware/Cors.php
View file @
681557b
<?php
namespace
App\Http\Middleware
;
use
Closure
;
class
Cors
{
class
CORS
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
*
* @return mixed
*/
public
function
handle
(
$request
,
Closure
$next
)
{
return
$next
(
$request
)
->
header
(
'Access-Control-Allow-Origin'
,
'http://contact.gotenzing.com'
)
->
header
(
'Access-Control-Allow-Methods'
,
'POST, GET, OPTIONS, PUT, DELETE'
)
->
header
(
'Access-Control-Allow-Headers'
,
'Content-Type, Accept, Authorization, X-Requested-With'
)
->
header
(
'Content-type: text/html'
);
;
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
;
}
}
\ No newline at end of file
...
...
app/Http/routes.php
View file @
681557b
...
...
@@ -30,7 +30,7 @@ Route::group(array('prefix' => 'api/v1'), function($json)
});
Route
::
any
(
'api/update'
,
[
'middleware'
=>
'cors'
,
'uses'
=>
'ApiController@update'
]
);
Route
::
any
(
'api/update'
,
array
(
'middleware'
=>
'cors'
,
'uses'
=>
'ApiController@update'
)
);
Route
::
any
(
'fileentry/postUpload'
,
'FileEntryController@postUpload'
);
...
...
bootstrap/app.php
View file @
681557b
<?php
// allow origin
header
(
'Access-Control-Allow-Origin: *'
);
// add any additional headers you need to support here
header
(
'Access-Control-Allow-Headers: Origin, Content-Type'
);
/*
...
...
Please
register
or
sign in
to post a comment