December 24th, 2020 by Alex Garrett-Smith

How to change the host and port of your Nuxt apps

For whatever reason (usually CORS), you'll need to change the host and port of your local Nuxt development server at some point.

How to do it

Add the following to your package.json file under the scripts section.

"dev-host": "nuxt --hostname yourdomain.test --port 3333",

Overall, your scripts section should look like this.

"scripts": {
"dev": "nuxt",
"dev-host": "nuxt --hostname yourdomain.test --port 3333",
"build": "nuxt build",
"start": "nuxt start",
"generate": "nuxt generate"

Of course, yourdomain.test can just be replaced with whatever domain you'd like to use. You can also change the name of the command from dev-host to whatever you'd prefer.

There are more ways!

Depending on your environment and preference, there are a few other ways to configure this. You'll find more over on the official Nuxt docs.