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

Udev's avatar
Level 2

Api requests on same server

After sending a curl/Http POST request to a secondary website on localhost, Laravel uses the database credentials of the initiator website also on localhost.

I don't understand why this is happening, maybe something to do with the session since they are on the same server? How can I test the APIs on localhost

0 likes
5 replies
Sinnbeck's avatar

Maybe start by explaining your dev set up.

Udev's avatar
Level 2

@Sinnbeck I am using Xampp with virtual hosts setup for both websites i.e.

vhost

<VirtualHost *:80>
    DocumentRoot ".../htdocs/.../public"
    ServerName localhost
</VirtualHost>
<VirtualHost *:80>
    DocumentRoot ".../htdocs/.../public"
    ServerName site2.test
</VirtualHost>

Host file

...ip...	localhost
...ip...	site2.test
Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

@Udev ok. I Don't use xampp. But I've heard of people with problems like this. Try caching config on both sites (remember to undo caching when you are done testing)

php artisan config:cache 
Udev's avatar
Level 2

@Sinnbeck Running config:chache on second website makes everything work as intended

Udev's avatar
Level 2

@Sinnbeck using php artisan serve with different ports also works. Yet to try with Vite or sail/docker.

Please or to participate in this conversation.