Understanding CORS Policy Errors for Preflight Requests

Asked 2 years ago, Updated 2 years ago, 160 views

Developed API in Laravel (5.7.0) and client-side applications in Angular (CLI 7.3.7).

Domainis
Angular: example.com
Ravel: api.example.com
and subdomain type.

serveris xserver.

The Angular app is that retrieves data by tapping the Larvel API, but

on the console.

Access to XMLHttpRequest at 'https://api.example.com/api/articles/ '
from origin'https://example.com'has been blocked by CORS policy:
Response to preflight request doesn't pass access control check:
Redirect is not allowed for a prelight request.

appears.

I'm at a complete standstill because I don't know if it's Larvel's problem, Angular's problem, htaccess, and so on.

Tap the API directly on Postman or Chrome to get the correct JSON response.

If you have any information that might be helpful, please let me know.

api laravel angular cors

2022-09-30 18:14

1 Answers

Judging from the error message, it appears to be due to a preflight request that occurs when the client hits the API and the server is not handling it correctly.Read the article around here to find out what the prelight request is.

Laravel needs to implement this preflight request.You can find useful information by searching for things like "Larvel CORS preflight".


2022-09-30 18:14

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.