I am using laravel-cors
when I attempt to access my api cross origin I get the phpinfo() ?
my app is hosted on staging.domain.io and my api is hosted on api.domain.io/v1
My code works on my local machine but when pushed to the staging domain the api loads up the phpinfo
I am hosting with digital ocean and using forge to setup the sites.
Sites I have setup are:
- staging.domain.io
- domain.io
- api.domain.io
If I remove api.domain.io from the list of sites the api returns an nginx 404 error :/
I have included my route service provider code below in hope it might help :S :
// Enviroment Var
APP_DOMAIN=domain.io
// Route provider
protected $endpoints = ['Core', 'Auth'];
foreach ($this->endpoints as $endpoint) {
$router->group([
'namespace' => 'Unite\Api\\' . $endpoint . '\Controllers',
'prefix' => 'v1', 'middleware' => 'cors',
'domain' => 'api.' . env('APP_DOMAIN', 'localhost') ],
function ($router) use ($endpoint) {
$route = $endpoint == 'Core' ? '/' : $endpoint . '/';
require app_path('Api/' . $route . 'routes.php');
});
}
Routes:
Route::get('/', function () {
return view('welcome');
});
Any help would be great!