Hello guys
I have a hard time to get angular and Laravel working together. I want to use Angular separately from Laravel. I have setup 2 domains app.domain.com and api.domain.com using forge. When i want to send requests from my app.domain.com or my localhost to my api.domain.com i got a CORS error.
XMLHttpRequest cannot load http://api.domain.com/api/authenticate. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8888' is therefore not allowed access.
I googled for hours but i can't figure it out. I already tried adding CORS middleware to Laravel but that has no effect.
{
return $next($request)
->header('Access-Control-Allow-Origin', '*')
->header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS')
->header('Access-Control-Max-Age', '1000')
->header('Access-Control-Allow-Headers', 'Content-Type, Authorization, X-Requested-With');
}
Error is still being showed. The weird part is that get request are allowed, only post requests are not allowed for some reason.
Can anyone help me out? Would be awesome!
Greets from Belgium
Jorn