Problem description
I am developing a web application with a React Frontend and PHP backend. For crossorigin and cookie Reasons I need to host the frontend on the same domain namespace as the backend. I need to access a deployed version of my backend with my local computer which hosts the fronend.
Previous solution
(Working only locally not on devices on the network)
For my Mac, I got it working reliably like this:
hosts
...
127.0.0.1 local.mydomain.com
::1 local.mydomain.com
...
New Solution
(not yet working as expected)
I implemented a DNS server on my Synology (disabled my Macs host entries) and set it up in my local network router like this:
Name | Type | TTL | Information |
---|---|---|---|
.local.mydomain.com | NS | 86400 | ns.local.mydomain.com. |
ns.local.mydomain.com | A | 86400 | 192.168.0.10 (local fixed IP of my computer) |
anothersub.local.mydomain.com | A | 86400 | 192.168.0.10 (local fixed IP of my computer) |
I also would like to instead of anothersub.local.mydomain.com
use *.local.mydomain.com
, however, when I did so, it always added a www
to the local.mydomain.com
on my iPhone like www.local.mydomain.com
which does prevent my app from working properly. On my Mac on the other hand, it works as expected. (Update: It is not, I forgot to disable some hosts entries)
I am not sure if it is some iPhone behavior but it seems like the iPhone always calls both local.mydomain.com
and www.local.mydomain.com
whenever I enter local.mydomain.com
. Generally my iPhone can access my app on my computer also on www.local.mydomain.com
, but it just doesn't work as expected.
mydomain.com
is a registered domain on the web, while I haven't registered the local.mydomain.com
subdomain on my webserver. I suspect, however, if my iPhone calls www.local.mydomain.com
it will somehow land on my webserver and not my local dns, getting an answer but of course not a success.
Is there any entry I can add to my DNS list to forward any call to www.local.mydomain.com
to local.mydomain.com
?
Updated question: how do I get local.mydomain.com
and not only anothersub.local.mydomain.com
working?
anothersub.local.mydomain.com
is working as expected, but just thelocal.mydomain.com
is notlocal.mydomain.com
to a local IP? Would this work as long as I am within my network?