Skip to content

Commit

Permalink
feat: allow to disable site auto-discovery
Browse files Browse the repository at this point in the history
  • Loading branch information
kyr0 committed Feb 23, 2024
1 parent d7ec630 commit 9e89760
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jsheaven/astro-client-generator",
"version": "1.1.3",
"version": "1.1.4",
"type": "module",
"publishConfig": {
"access": "public"
Expand Down
4 changes: 3 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export interface ApiClientGeneratorOptions {
parser?: 'naive' | 'baseline'
/** site URL to request from. Optional, usually auto-discovered from Astro config */
site?: string
/** disable auto-discovery of site URL, default: false */
disableSiteAutoDiscovery?: boolean
}

export const apiGeneratorOptionsDefaults: ApiClientGeneratorOptions = {
Expand Down Expand Up @@ -90,7 +92,7 @@ export const apiClientGenerator = (
`http://${address.address}:${address.port}` :
`http://[${address.address}]:${address.port}`

if (apiGeneratorOptions.site && apiGeneratorOptions.site !== actualSite) {
if (apiGeneratorOptions.site && apiGeneratorOptions.site !== actualSite && !apiGeneratorOptions.disableSiteAutoDiscovery) {
console.log(`🔄 Endpoint host has changed to ${actualSite}. Updating site accordingly.`)
apiGeneratorOptions.site = actualSite
}
Expand Down

0 comments on commit 9e89760

Please sign in to comment.