fix(nuxt): accept any `baseURL` when fetch response type is named by danielroe · Pull Request #36523 · nuxt/nuxt · GitHub
Skip to content

fix(nuxt): accept any baseURL when fetch response type is named - #36523

Merged
danielroe merged 1 commit into
mainfrom
fix/fetch-inferred-url
Oct 9, 2026
Merged

danielroe merged 1 commit into
mainfrom
fix/fetch-inferred-url

Conversation

@danielroe

Copy link
Copy Markdown
Member

🔗 Linked issue

resolves #36521

📚 Description

since 4.6.0, naming the response type of a call meant it no longer accepted a baseURL, even though it worked in 4.5.x:

useFetch<{ items: number[] }>('/x', { baseURL: useRuntimeConfig().public.apiBase })
// TS2769: No overload matches this call.
//   Type 'string' is not assignable to type '"" | Ref<"" | undefined, "" | undefined> | ...'

this was becase a call that named one type argument couldn't infer the others, so the base falls back to its '' default.

so this PR makes the default string when the request type has fallen back to its own default...

@coldtea-pr-lens

coldtea-pr-lens Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

@github-actions github-actions Bot added 5.x 🐛 bug Something isn't working as expected labels Oct 9, 2026
@pkg-pr-new

pkg-pr-new Bot commented Oct 9, 2026

Copy link
Copy Markdown

Open in StackBlitz

@nuxt/kit

pnpm add https://pkg.pr.new/@nuxt/kit@36523
npm i https://pkg.pr.new/@nuxt/kit@36523
yarn add https://pkg.pr.new/@nuxt/kit@36523.tgz

@nuxt/nitro-server

pnpm add https://pkg.pr.new/@nuxt/nitro-server@36523
npm i https://pkg.pr.new/@nuxt/nitro-server@36523
yarn add https://pkg.pr.new/@nuxt/nitro-server@36523.tgz

nuxt

pnpm add https://pkg.pr.new/nuxt@36523
npm i https://pkg.pr.new/nuxt@36523
yarn add https://pkg.pr.new/nuxt@36523.tgz

@nuxt/rspack-builder

pnpm add https://pkg.pr.new/@nuxt/rspack-builder@36523
npm i https://pkg.pr.new/@nuxt/rspack-builder@36523
yarn add https://pkg.pr.new/@nuxt/rspack-builder@36523.tgz

@nuxt/schema

pnpm add https://pkg.pr.new/@nuxt/schema@36523
npm i https://pkg.pr.new/@nuxt/schema@36523
yarn add https://pkg.pr.new/@nuxt/schema@36523.tgz

@nuxt/vite-builder

pnpm add https://pkg.pr.new/@nuxt/vite-builder@36523
npm i https://pkg.pr.new/@nuxt/vite-builder@36523
yarn add https://pkg.pr.new/@nuxt/vite-builder@36523.tgz

@nuxt/vite-server

pnpm add https://pkg.pr.new/@nuxt/vite-server@36523
npm i https://pkg.pr.new/@nuxt/vite-server@36523
yarn add https://pkg.pr.new/@nuxt/vite-server@36523.tgz

@nuxt/webpack-builder

pnpm add https://pkg.pr.new/@nuxt/webpack-builder@36523
npm i https://pkg.pr.new/@nuxt/webpack-builder@36523
yarn add https://pkg.pr.new/@nuxt/webpack-builder@36523.tgz

commit: 14ae321

@coderabbitai

coderabbitai Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d0b7ba4b-fa42-463d-8b64-2072dd1c8ae6

📥 Commits

Reviewing files that changed from the base of the PR and between 48412f7 and 14ae321.


📒 Files selected for processing (3)
  • packages/nuxt/src/app/composables/fetch.ts
  • packages/nuxt/src/app/types/fetch.ts
  • test/fixtures/basic-types/app/fetch-types.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.



Walkthrough

Fetch type defaults now account for request constraints and explicit response types. The changes update TypedFetch and useFetch signatures, including configured fetch instances. Type fixtures check baseURL values, contextual response typing, and rejection of an invalid route.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 14ae3

No actionable merge-blocking issue is established. Run the type fixtures as part of normal checks.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check Passed The title clearly states the primary change: allowing any runtime baseURL when a fetch response type is explicitly named.
Description check Passed The description directly explains the TypeScript error, the affected fetch APIs, the cause, and the intended fix.
Linked Issues check Passed The changes address the coding requirements in #36521. FallbackBaseURL uses string when request inference falls back to its default and keeps '' while the request remains inferred. TypedFetch,…
Out of Scope Changes check Passed The diff is limited to fetch type defaults, the related useFetch overloads, and compile-time tests for the reported behaviour. These changes directly support #36521. No unrelated product behaviour o…
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 3 files.


✨ Finishing Touches 💡 1
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR

🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR


🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@danielroe
danielroe enabled auto-merge October 9, 2026 11:11
@danielroe
danielroe added this pull request to the merge queue Oct 9, 2026
Merged via the queue into main with commit a44843a Oct 9, 2026
62 of 64 checks passed
@danielroe
danielroe deleted the fix/fetch-inferred-url branch October 9, 2026 11:41
@github-actions github-actions Bot mentioned this pull request Oct 9, 2026
@github-actions github-actions Bot mentioned this pull request Oct 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

5.x 🐛 bug Something isn't working as expected

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4.6.0: useFetch<T>() / useLazyFetch<T>() reject a string baseURL (TS2769) — BaseURL generic defaults to '' when the response type is given explicitly

1 participant