Nuxt subdomain only works with localhost

Viewed 120

I need to get subdomain on Nuxt. So I use const domain = window.location.hostname and it works perfectly fine when for exemple I try exemple.localhost:3000 But when I try to change the hosts and try to do exemple.mydomain:3000 my browser can't find it while mydomain:3000 works

nuxt launch script as dev:

nuxt --hostname 'mydomain' --port 3000

and etc/hosts :

127.0.0.1       localhost       mydomain      mydomain.local

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

nuxt.config.js :

server: {
    host: 'mydomain'
    port: 3000
}
0 Answers
Related