Do not use localhost:3000 as default in production
See original GitHub issueWhat problem does this feature solve?
If eveything else fails, baseURL will default to http://localhost:3000.
While this is nice in dev environement, it might cause production environement to use http://localhost:3000 as default, if not configured properly.
This lead to error in my deployment because I didn’t configure the module correctly but din’t realise my mistake until it was too late.
I believe that a better behaviour would be to throw ASAP in that case, preventing the deployment of faulty code.
What does the proposed changes look like?
let defaultPort =
// ...
(process.env.NODE_ENV === 'development' && 3000)
let defaultHost =
// ...
(process.env.NODE_ENV === 'development' && 'localhost')
if (!defaultPort || !defaultHost) throw new Error('Configuration error')
<div align="right">This feature request is available on Nuxt community (#c267)</div>Issue Analytics
- State:
- Created 4 years ago
- Reactions:11
- Comments:12 (8 by maintainers)
Top Results From Across the Web
What is localhost 3000? - reactjs - Stack Overflow
Localhost means that it's your computer that is hosting the app, and it doesn't mean that it's accessible on other computers. 3000 is...
Read more >You should never ever run directly against Node.js in ...
First off, let's address the statement “never run apps directly against Node in production”. Never run directly against Node in production.
Read more >Express/Node introduction - Learn web development | MDN
With the server running, you could go to localhost:3000 in your browser to see the example response returned. Importing and creating modules. A ......
Read more >How to Easily Set-up Node Config (Best Practices)
Putting the default port on which the app will bind into the code is not really an issue; however, the login credentials for...
Read more >Server Options - Vite
The first case is when localhost is used. Node.js under v17 reorders the result of DNS-resolved addresses by default. When accessing localhost ,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is a really confusing default behavior, it took me a while to figure out why my API calls were failing. I agree with @matthieusieben – when I say
/api/foo
, it is logical to expect that this request will go to the same host/port as the page that is calling it.@manniL Indeed
baseURL
is auto-generated with port/host of the listener server if not provided:https://github.com/nuxt-community/axios-module/blob/dev/lib/module.js#L17
This issue is requesting to make setting
baseURL
manually mandatory for non-dev and not using server host/port to generate it.