Laravel Blocked by CORS

Hello, I have a website created in 2 parts, the back end with Laravel and the front end in React. In the root folder, I have created a folder called: React-Laravel which contains the index.html and the assets generated by React, and inside there is another folder called: laravel which contains all the Laravel code. The issue is that I am having trouble performing PUT and DELETE operations from the React front end. I can get the list of products with a GET request and can add new products, but I cannot update or delete them because I get a CORS error which is as follows:

(redirected from ‘https://mydomainnotreal.wuaze.com/React-Laravel/laravel/public/api/productos/19’) from origin ‘https://mydomainnotreal.wuaze.com’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. If an opaque response serves your needs, set the request’s mode to ‘no-cors’ to fetch the resource with CORS disabled.

And I can’t find a way to solve it, this is due to the policies of infinityfree, is there any way to solve it?

We have blocked such type of requests on our server, so it will not work here.

Laravel has an alternate way of using _method=xxx arugument in POST requests, you probably wanted to use that here.

As of the CORS error, it was probably that such requests raises an 403 error, which then redirects to our 403 page, which is on a different domain and raises the CORS error. So it was actually not the true issue here.

4 Likes

Thank you, that clarifies everything. Something I would like to suggest is that they increase the size limit for PHP files to more than 1MB, as there are some Laravel 11 files that I was unable to upload to the server because they weighed slightly more or more than 1 MB, they do not affect my case but in other projects they could affect. I think a limit of 5 MB would be the best for the future.

Unfortunately, I was just a normal user.

What might surprised you is that Admin is also unable to do you anything on this request. InfinityFree is after all, a reseller, and we must go with whatever limit that the actual server providers set.

Thankfully, PHP files are actually easy to be split up. I didn’t use Laravel much, you might be able to check whether you can generate the Laravel files to be smaller and be in chunks.

4 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.