CORS requests between Laravel applications uses wrong database


  • | 410 points

    Hi guys,

    Anyone ever had an issue with CORS requests between two Laravel applications not working properly because the requested application starts using the database from the original application?

    I work on a lot of internal tools in my company, let's say an ERP, a dashboard, an invoice manager and more. All of these services might need data from a centralized database (logging for example).

    When for example our ERP makes requests to our centralized database it might happen that the centralized database tries to access the database of the ERP with the tables of the centralized database, and returns a session token that is from the ERP and not the centralized database.

    The ERP is using the URL erp.company.com.test and the centralized database is using the URL company.com.test, databases are both named after the URL.
    Never had the issue on my MacBook pro using Laravel Valet nor on our staging/production environments (thanks god) but it makes development on Windows with Laragon quite challenging.

    The issue was temporarily patched when we changed the ERP's url to erp-company.com.test has I was thinking the CORS request was having an issue when using a subdomain but the issue seem to happen again...

    Anyone ever encountered the same issue?

    Thanks in advance to anyone helping and happy holidays!


  • administrators
    | 118386 points

    @fhusquinet : Have you tried using Nginx as web server?


  • | 410 points

    This post is deleted!

  • | 410 points

    Didn't think of that, but indeed that seem to have done the trick!

    Thanks a lot, no more headaches because of that anymore! 😅


Log in to reply
 

Looks like your connection to Laragon was lost, please wait while we try to reconnect.