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

sakon54321's avatar

Laravel 11 & Herd api not working on .test domain with mobile

Hi,

I'm sure I'm overlooking something small here. I just moved to using Laravel Herd on my system and also upgraded a project to Laravel 11. I'm using the Laravel project as an API backend for a mobile app. So I've installed Sanctum.

In previous Laravel 9/Valet setup I'd serve the Laravel API with npm run dev and vite. From the mobile app I could hit the backend on http://projectname.test/api/... everything was fine.

In this setup with Laravel 11/Herd even though I can use the browser to hit the api endpoint using http://projectname.test/api/ it doesn't seem to work when i get the mobile app to hit the same endpoint.

It give me a Network Error that looks like a CORS issue.

{"message":"Network Error","name":"Error","stack":"createError@\nhandleError@","config":{"url":"http://192.168.1.251:8000/api/test-api","method":"get","headers":{"Accept":"application/json, text/plain, */*","X-Requested-With":"XMLHttpRequest"},"baseURL":"http://projectname.test/api/","transformRequest":[null],"transformResponse":[null],"timeout":0,"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","maxContentLength":-1,"maxBodyLength":-1,"transitional":{"silentJSONParsing":true,"forcedJSONParsing":true,"clarifyTimeoutError":false}}}

Interestingly if I serve the Laravel 11/Herd app using the php artisan serve --host=192.168.1.251 --port=8000 command everything works fine. It's not a big issue since I can still work but if someone knows what I'm doing wrong it would be appreciated.

0 likes
4 replies
ilyasabdut's avatar

im having this issue as well, im migrating from valet. i think i'll go back

sakon54321's avatar

I finally got it working. Seems like it was actually a problem with my Cordova build (which I also upgraded!!). Needed to add the following lines

    <access origin="http://projectname.test" />
    <allow-navigation href="http://projectname.test/*" />
chrisje59's avatar

Thank you for raising this issue! I was having the same problem with a Laravel 8 app.

Looking carefully through the .env file on my local dev installation, I noticed that I had a typo in the APP_URL= variable.

Setting that right and subsequently running the "php artisan config:clear" CLI command fixed the issue..

D0nVitalio's avatar

Herd cuts Authorisation header. Switched to php artisan serve

Please or to participate in this conversation.