fix(nuxt): fix broken external urls when baseURL is set in config #8205
Conversation
Set baseURL for ohmyfetch $fetch dynamically through onRequest interceptor
Β Open in CodeSandbox Web Editor | VS Code | VS Code Insiders |
β Deploy Preview for nuxt3-docs canceled.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
-> also posted in https://github.com/nuxt/framework/issues/7983#issuecomment-1279743702
Ok. Would you mind if I had a look at ufo and try to fix it there? Alternatively I can close this PR. |
Taking a look upstream would be lovely π |
Quick update/note: seems like the issue is boiled down to |
@danielroe the fix to that problem was already committed 3 months ago to the unjs/ufo. There was a patch which introduced check for Looking at unjs/ohmyfetch repo after pnpm install, it's clear that the old version of the ufo is installed since there's no The solution: update the version of unjs/ufo in unjs/fetch (probably releasing a new version first for ufo). This branch can be safely disregarded after that. |
Thanks for investigating. β€οΈπ |
@pi0 shall i release new versions of |
|
π Linked issue
nuxt/nuxt#15082
β Type of change
π Description
Resolves nuxt/nuxt#15082 - set baseURL for ohmyfetch dynamically through interceptor. The urls were prefixed with baseURL even if they were external.
Using onRequest method of ohmyfetch we set a request interceptor which checks for:
If both are true, it sets the baseURL to
''
(allowing external link calls). Otherwise if not already in request config - sets the baseURLπ Checklist