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

prex016's avatar

Rest API

I am using angular and for rest-API laravel.

In env my APP_URL=https://www.domain.com.

So, when I open my website from https://www.domain.com, it hits to rest API correctly. but when I open the website from https://domain.com, laravel API does not hit. I have checked apache access log: I found request there but not in laravel!

0 likes
7 replies
ftiersch's avatar

Do you mean it doesn't hit laravel at all or it doesn't show the result?

ftiersch's avatar

If it hits Apache but doesn't hit Laravel it's probably an Apache configuration issue

prex016's avatar

@FTIERSCH - ok, thanks for point out on it. However, I still need to find out what configuration might be caused to it. Is that COR related issue possible in that case?

ftiersch's avatar

I actually had exactly the same problem just two hours earlier, where it is a COR issue :D

But if it doesn't hit your Laravel application at all it's not a COR issue, because that would be handled in the browser only. So it would hit your application, return the data and the browser would say "nope, that's invalid data because it's from a bad resource"

1 like
Mindexperiment's avatar

This is an apache problem.. you need to add a server alias rule inside you .conf file

<.. *:80>
 ServerName www.domain.com
 ServerAlias domain.com
</>

better if you invert the rules, www is a sub domain of your top level domain

<.. *:80>
 ServerName domain.com
 ServerAlias www.domain.com
 DocumentRoot /path/to/your/root/folder
</>

Please or to participate in this conversation.