Laravel 5 AngularJS CORS issue - laravel

Folks i am new to Laravel and trying to do Authentication from AngularJS for which i need to set-up CORS in Laravel 5.
Tried setting-up CORS middleware.
Tried setting-up: https://github.com/barryvdh/laravel-cors
Tried putting CORS headers in index.php
None of the above solutions works for me please if someone can just guide me a little.
Much appreciated.

If you get CORS exception error in browser, it may because of another exception. with laravel-cors package if your application excepted any exception, CORS exception throwed.
Check your laravel.log file for more details

Related

Laravel api blocks all requests with CORS

I have a problem with all my requests sent in javascript on the api. They are all blocked by the CORS. When they are sent from postman, they work fine.
The fruitcake/laravel-cors library is already installed but has not fixed the problem.
Do you have any solutions?
Thank you in advance.
Remove this fruitcake/laravel-cors package .Now Laravel 9 by default provides cors solution.
Visit site from http://localhost:8000 not http://127.0.0.1:8000
I am on laravel 8, and access to the api does not work in production.
Everything was working normally and since reinstalling the vps (on apache) it doesn't work anymore.
I don't know if it's apache or laravel.

Forbidden 403 Access URL API in Laravel

Good afternoon, let me ask
I created a service API using Laravel, but one of the API urls when I sent the response parameter was 403 or Forbidden. even though before it was fine, it worked smoothly. And I raised it to the server instead it became Forbide. Anyone know why? thank you for answering
If it is ok on local and getting a forbidden error on the server, the problem might be caused by the webserver application. please take a look at this link.

Why did Not working Laravel middleware CORS with Vue.js

working with Laravel 5.7 as backend and Vue.js as frontend. so, I need send http request fron Vue to Laravel backend. so, I used Laravel CORS package to using github link as following https://github.com/barryvdh/laravel-cors but it is not sucess and (not pass data to table fron vue). and my console error is `Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:8000/api/addItem. (Reason: CORS request did not succeed).
how can fix this error?`
It is only for localhost & in production if you use https then this issue will not raise any more. However for local test you can open chrome browser in disabled security mode. Details about how to do
Access-Control-Allow-Origin (Laravel & Vue)

Can Error 419 (unknown status) be related to something other than CSRF-Token?

I'm not managing to solve a problem related to the mentioned error in my application.
Looking for a solution I only find information about how to handle CSRF-tokens and can find anything else, is it possible that if I get this error it has to be a problem with the token?
I'm sending a post requests with axios, from a vue component to Laravel.
Edit: I didn't add the code because I know there are already a lot of threads talking about this, I was just wandering if anyone has ever got this error in some case other than CSRF-token related issue.
set in your axios code request
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
and set cookie
xmlhttp.setRequestHeader('X-CSRF-TOKEN',window.Cookies.get('_csrf'));
If you are using web routes to call as API then you would get this error on POST request. Please define the API routes in api.php and it will start working.

Response for preflight has invalid HTTP status code 404

This is the responce i am getting when trying to upload a file from my client(PHP),My server is on WebApi which is hosted in one server.In my webapi i have allowed all CORS related things still i am getting this error.
Have you checked this tutorial?
Maybe when you say
In my webapi i have allowed all CORS related things
you didn't do that correctly, or maybe you enabled too many options at the same time.
It's hard to give you more details without access to your actual configuration.
There are also many posts on the same subject here on SO, have you checked them?

Resources