Skip to content

[Feature Request] Option to resolve BaseUrl at runtime #2581

@chcederquist

Description

@chcederquist

Problem

An API may be present on several different servers. When building a JS bundle, you don't necessarily want to couple that bundle to a single API. However, that is the case with the baseURL, which doesn't have a way to be set at runtime, other than through using a transformer override.

Feature Request

I would like to be able to point the base URL to a runtime variable or a function that resolves it the same you do with custom fetch clients or JSON revivers. E.g.
{... baseUrl: { resolve: './baseUrlResolve.ts'} }

// baseUrlResolve.ts
function getBaseUrl() {
  return window.apiBaseUrl;
}
export default getBaseUrl

The function would be called every time the base URL was to be resolved.

Alternatively a static variable could be referenced:
{... baseUrl: { variable: 'window.baseUrl'} }

Metadata

Metadata

Assignees

No one assigned

    Labels

    axiosAxios related issuefetchFetch client related issue

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions