Skip to content
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

Make port optional #100

Closed
dekadentno opened this issue May 13, 2020 · 9 comments · Fixed by #103
Closed

Make port optional #100

dekadentno opened this issue May 13, 2020 · 9 comments · Fixed by #103

Comments

@dekadentno
Copy link

dekadentno commented May 13, 2020

What problem does this feature solve?

The port should be optional because there are many public (and non public) APIs that don't require the port in the Request URL.

What does the proposed changes look like?

In nuxt.config.js it should be possible to do

  http: {
    host: 'bla.bla.com',
    port: null, // or `false`
    prefix: '/v1' 
  }
@ghost ghost added the cmty:feature-request label May 13, 2020
@dekadentno
Copy link
Author

I can try to resolve this and submit a pull request, but I am not sure why the port would be mandatory in the first place, maybe there's a reason but I don't see it.

@ricardogobbosouza
Copy link
Contributor

Hi @dekadentno
Just use the baseURL option

http: {
  baseURL: 'https://bla.bla.com/v1'
}

@dekadentno
Copy link
Author

Hi @dekadentno
Just use the baseURL option

http: {
  baseURL: 'https://bla.bla.com/v1'
}

Hi @ricardogobbosouza
I've tried that. Also not possible because it automatically adds the default port (3000) at the end of the baseURL. Check line 20 here:
https://github.com/nuxt/http/blob/dev/lib/module.js

@ricardogobbosouza
Copy link
Contributor

The options are overwritten, see
https://github.com/nuxt/http/blob/dev/lib/module.js#L38

@dekadentno
Copy link
Author

dekadentno commented May 21, 2020

The options are overwritten, see
https://github.com/nuxt/http/blob/dev/lib/module.js#L38

I understand what you are trying to say, but I still get the default port at the end of my baseURL on every request. My nuxt.config.js looks just like the one you wrote in your comment.

Edit: I'll make a repo with my problem this weekend.

@ricardogobbosouza
Copy link
Contributor

@dekadentno
I await the Repo

@pi0
Copy link
Member

pi0 commented May 26, 2020

I agree with @ricardogobbosouza to use baseURL to override. But could be also nice enhancenment to omit the port if is matching scheme (https/443 http/80)

@dekadentno
Copy link
Author

Thank you for your answers and your time @ricardogobbosouza @pi0
I am very ashamed but I have to let you know that the source of my problems was in my baseUrl because the currect spelling is baseURL 😅 I noticed that right now while trying to reproduce my problem in a separate repo so I can upload it for you guys.

I hope my mistake will help some future lurkers because I spent more than a week on this issue in vain.

@pi0
Copy link
Member

pi0 commented May 27, 2020

@dekadentno Actually nothing to sorry and thanks for report. I saw baseUrl misspelling multiple times. It is not module bug but a DX bug that we should handle properly. Will push fix for both :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants