Replies: 1 comment 1 reply
-
By default, Laravel returns a standard syntax error message when an exception occurs. However, if you're encountering CORS errors instead, you can update your exception handler to return the standard Laravel syntax error message instead. This will make debugging your code much easier and prevent CORS errors from disrupting your development workflow.
This code will catch any syntax errors that are causing your code to crash, and return a standard Laravel JSON error message instead of a CORS error. Save the file and test your code again. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Description:
I still get the CORS-error when an 500-error occurs on the server.
For example, if I make a syntax error in the code, causing the application to crash, then the headers will not be set and the browser will show CORS errors.
That is, code execution does not reach
\Illuminate\Http\Middleware\HandleCors::class
inapp/Http/Kernel.php
if there is a 500-errorInstalled clean Laravel and intentionally made a mistake in the code, and again I see the CORS-error, instead of an error message.
It is no longer possible to quickly identify the source of an error in the console during development SPA
I have to open the log file all the time, without normal highlighting
Steps To Reproduce:
in routes/api.php
result: CORS-error
expect: standard Laravel syntax error message
Beta Was this translation helpful? Give feedback.
All reactions