How to change the host and port of your Nuxt apps

December 24th, 2020

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

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.

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.

Thanks for reading! If you found this article helpful, you might enjoy our practical screencasts too.
Alex Garrett-Smith
Share :


No comments, yet. Be the first to leave a comment.

Tagged under