question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

baseUrl default port is :3000 even when nuxt use a random port

See original GitHub issue

Version

v5.8.0

Reproduction link

https://codesandbox.io/

Steps to reproduce

  1. Run nuxt dev when port 3000 is already in use
  2. Nuxt will start on a random port
  3. Do not edit the axios object in nuxt.config.js
  4. Call to localhost will fail because they will use port 3000 instead of random nuxt port

What is expected ?

Axios should use process.env. NUXT_PORT

What is actually happening?

Axios default to port 3000

Additionnal info

I do this because I load json data hosted in the static folder. I can’t use import as these fill will be updated regularly via a setInterval

<div align="right">This bug report is available on Nuxt community (#c302)</div>

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:1
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
mrleblanc101commented, Nov 20, 2019

Setting baseURL: '/' did the trick, but it’s weird I feel like if I do not set the baseURL, it should bind to the correct port

1reaction
manusiakemoscommented, Apr 21, 2022

work for me with this config

 axios: {
    baseURL: "http://localhost:8000",
    browserBaseURL: "http://localhost:8000",
  },

Read more comments on GitHub >

github_iconTop Results From Across the Web

Nuxt/Axios: baseURL with same origin, but different port ...
The problem is, when I access my frontend (for example 192.168.1.XXX:3000 ), all axios api requests are still sent to http://localhost:8800/api/ ...
Read more >
Configuration - Nuxt
By default, Nuxt is configured to cover most use cases. ... You can also change the port number from the default port of...
Read more >
scribe.config.js
The baseUrl key is the base URL Scribe will make requests to. Typically, this should be the URL (+ port) your app runs...
Read more >
Build an API with Node.js, Express, and TypeScript - Split
Build a RESTful API using Node.js, TypeScript, and Express. ... the server will run on port 3000 , with the base URL where...
Read more >
Nuxt: The Hard Parts - Jonas Galvez
api' export default { serverMiddleware, modules: ['@nuxt/http'], server: { port: 3000 }, http: { baseURL: 'http://localhost:3000' } }.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found