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

useFetch/$fetch and external URLs is broken when used in an app configured with a baseUrl #15082

Closed
kiddicodes opened this issue Oct 4, 2022 · 2 comments

Comments

@kiddicodes
Copy link

kiddicodes commented Oct 4, 2022

Environment

  • Operating System: Darwin
  • Node Version: v16.17.1
  • Nuxt Version: 3.0.0-rc.11
  • Nitro Version: 0.5.4
  • Package Manager: npm@8.15.0
  • Builder: vite
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Reproduction

https://stackblitz.com/edit/nuxt-starter-fsyggj?file=app.vue

Having a hard time reproducing the exact issue that I'm having. But this basic setup isn't working either so hopefully related.

Added two examples in App.vue (one of the commented out).

Describe the bug

When using baseUrl config (either by ENV or nuxt.config) useFetch / $fetch isn't working properly with external URLs.

Not entirely sure what is going on, basically what happens locally in my own project is that when using an external url (e.g. https://graphql.contentful.com/content/[...]) it gets called with a starting '/' which makes the url relative and of course resulting in a 404 (e.g. /https://graphql.contentful.com/content/[...]).

I can't reproduce this in stackblitz, what happens there instead is that the call is made over and over again, never returning any data. It is like it's stuck in a recursive loop. Removing the baseUrl configuration resolves the issue.

Additional context

No response

Logs

No response

@danielroe
Copy link
Member

This seems like an upstream bug to me, and we should likely resolve in ufo or ohmyfetch.

Previously we had a similar bug which was resolved in unjs/ufo#68.

@kiddicodes
Copy link
Author

kiddicodes commented Oct 25, 2022

@danielroe @Araneline I can confirm that once I've created a new package-lock file I now get ufo@0.8.6 as a dependency and everything seems to be working fine. Also solves the repro linked initially.
Thanks for your help 👍 😎

(for others reading this, there was a discussion in the PR mentioned above that is now closed regarding the version of ufo)

@danielroe danielroe added the 3.x label Jan 19, 2023
@danielroe danielroe transferred this issue from nuxt/framework Jan 19, 2023
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.

2 participants