Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

EverdevFR's avatar

CORS authorization

Hello everyone,

I don't know if I'm on the right channel but I would like to know how to authorize a request to the Laravel API from the browser code of a website developed in another language?

Here is the context:

I have a RESTful API developed with Laravel 11 and I have a web application developed in WLanguage which makes a request to the Laravel API in javascript.

At run time, Chrome gives me this error message: Access to XMLHttpRequest at 'http://127.0.0.1:9000/test' from origin 'http://127.0.0.1' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Despite several days of research, I don't know if I misconfigured Laravel, my IIS server or even my javascript request...

Could anyone help me with this bug?

Sincerely, Yann

0 likes
3 replies
EverdevFR's avatar

@DhPandya Thank you for this post. I managed to do what I needed to.

I would like to know how Laravel can accept an "Origin: 127.0.0.1" header when its domain is "api.domain.test"?

Because for the moment es 2 must be in the same domain but to allow me to test my web application locally to the API remotely, I need to authorize it.

DhPandya's avatar

@EverdevFR What I prefer is to go with creating a VirtulHost in the local development environment. In my most cases VirtualDomain solves the CORS issue. (I'm not sure whether it could be a good way or not. Sorry for that)

1 like

Please or to participate in this conversation.