im having this issue as well, im migrating from valet. i think i'll go back
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.
Please or to participate in this conversation.