I setup magento 2.2.0 in developer mode to work via dev.example.com internally by setting up magento with nginx and then doing host overrides in the firewall. Everything works great locally.
Next i setup NAT in the firewall so that someone could hit the dev site remotely by going to <publicIP:PORT>. At first each time they visited the site remotely, it would try to redirect to example.com which of course we don't own so that didn't work. Next i went in the magento dev interface Stores>Configuration>Web>"Url Options" and set "auto-redirect to Base URL" to "NO". It was set to use system value which was "Yes 302 Found".
After making that change and doing a cache flush under "System>Cache Management", now external access from <public IP:PORT> is working and not redirecting, but css/js isn't working. There is no styling.
In the console I have
Uncaught SyntaxError: Unexpected token < require.js:1
Uncaught SyntaxError: Unexpected token < mixins.js:1
Uncaught SyntaxError: Unexpected token < requirejs.config.js.js:1
Uncaught TypeError: require.config is not a function <publicIP>/:145 at <publicIP>/:145
All internal access is still working perfectly via dev.example.com for both admin and store front. It's just external that has this problem after making the above change to prevent a request from <publicIP:PORT> from redirecting to the domain since that domain only works internally.
After trying to flush the cache again I also have the following in the console with remote request in addition to the other error messages above:
Resource interpreted as stylesheet but transferred with MIME type text/html: "http://dev.example.com/?f"
Which tells me that the redirect setting i turned off doesn't apply to styles.
How do you correct the error above so that access remotely works via the IP and still has styling?
1 Answer 1
I changed the "auto-redirect to Base URL" back to the defaults and just set Stores>Configuration>Web>"Base Url" to http://<publicIP:PORT>/ instead of http://dev.example.com/.
Flushed Magento Cache and everything's working internally and remotely.