-
Notifications
You must be signed in to change notification settings - Fork 245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do not use localhost:3000 as default in production #274
Comments
Hi. I see the problem but the fact is that we cannot predict deployment type during build to find out correct URL. One thing i would suggest is using proxy module which serves API on same domain/port for client-side |
One could argue that not using any default (in dev and prod) would be better as showing an error in dev will ensure that the developer is aware of the config he will need to setup in prod. But that would be a breaking change... |
It depends on use case. Not always defaults are required. When using baseURL or absolute URLs for making requests is possible. |
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 |
@pi0 Do you think we should throw a warning in production mode if the host is |
@ricardogobbosouza I'm not sure. Because one may just register a serverMiddleware to serve API requests without any proxy and relative URL. For production (server-side) |
Well remembered, we can't do everything for the user 😬 |
@pi0 Couldn't we align the baseURL with what the port + host is set to in dev mode? 🤔 |
@manniL Indeed https://github.com/nuxt-community/axios-module/blob/dev/lib/module.js#L17 This issue is requesting to make setting |
Ohh, I got it wrong then 🙈 |
I may not be understanding the code, but I think this issue bit me. These two configurations in nuxt.config.js work fine: // Server Configuration or // Server Configuration This one breaks: // Server Configuration I think because of /* istanbul ignore if */ I'm getting errors when my dev machine gets an IP address but axios defaults baseURL to localhost not the IP address that is assigned when you use 0.0.0.0 in the configuration. |
What 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?
The text was updated successfully, but these errors were encountered: