After trying the old solution without success, I decided to refer to the Nuxt 3 documentation for answers, only to find that it was not up to date.
So, is there a way to change the Nuxt 3 port without modifying the dev script, similar to what @kissu did here?
I initially attempted to make the change in /.nuxt.config.ts:
export default defineNuxtConfig(
server: {
port: 8080,
},
})
However, this resulted in the URL being set to http://localhost:3000.
Update:
I later discovered a solution involving the use of an .env file:
Simply add the following line to your .env file located in the project root directory:
PORT=8080
Nuxt 3 will automatically detect this change from your environment variable.