which-url 0.0.3 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -7,132 +7,156 @@ npm install which-url
7
7
  ```
8
8
 
9
9
  ```typescript
10
- import appUrl from 'which-url'
10
+ import { origin } from 'which-url'
11
11
 
12
- auth({ baseURL: appUrl.href }) // just works — local, preview, production
12
+ auth({ baseURL: origin })
13
+ fetch(`${origin}/api/data`)
13
14
  ```
14
15
 
15
- Works on Vercel, Netlify, Cloudflare Pages, Railway, Fly.io, Render, DigitalOcean, and Heroku — automatically.
16
+ ```
17
+ origin env
18
+ Local http://localhost:3000 "local"
19
+ Preview https://myapp-git-feat.vercel.app "preview"
20
+ Production https://myapp.com "production"
21
+ ```
16
22
 
17
- ## Usage
23
+ Works across environments (local, preview, production), runtimes (server, client, edge), and [platforms](#platform-support).
18
24
 
19
- ### Default export (object with dot access)
25
+ The default export gives you everything as an object:
20
26
 
21
27
  ```typescript
22
28
  import appUrl from 'which-url'
23
29
 
24
- appUrl.href // "https://myapp.vercel.app"
25
- appUrl.origin // "https://myapp.vercel.app"
26
- appUrl.hostname // "myapp.vercel.app"
27
- appUrl.host // "myapp.vercel.app"
28
- appUrl.protocol // "https:"
29
- appUrl.port // ""
30
-
31
- appUrl.env // "production" | "preview" | "local"
32
- appUrl.isProduction // boolean
33
- appUrl.isPreview // boolean
34
- appUrl.isLocal // boolean
30
+ appUrl.origin // "https://myapp.com"
31
+ appUrl.hostname // "myapp.com"
32
+ appUrl.protocol // "https:"
33
+ appUrl.env // "production"
34
+ appUrl.platform // "vercel"
35
+ appUrl.isProduction // true
35
36
  ```
36
37
 
37
- Property names follow the [WHATWG URL spec](https://url.spec.whatwg.org/) — nothing new to learn.
38
+ ## The problem
38
39
 
39
- ### Named exports (plain stringszero type friction)
40
+ Your app's base URL shows up everywhere OAuth callbacks, API calls, CORS, emails. Every one of these breaks if the URL is wrong:
40
41
 
41
42
  ```typescript
42
- import { href, hostname, origin, isProduction } from 'which-url'
43
+ // Auth needs the exact URL for OAuth redirects
44
+ auth({ baseURL: ??? })
43
45
 
44
- // Pass directly to any function that expects a string
45
- process.env.BETTER_AUTH_URL = href
46
- fetch(`${href}/api/data`)
47
- cookie.domain = hostname
46
+ // API calls from the client
47
+ fetch(`${???}/api/data`)
48
48
 
49
- if (isProduction) {
50
- // production-only logic
49
+ // Emails — links need to point somewhere real
50
+ `Click here to verify: ${???}/verify?token=${token}`
51
+
52
+ // CORS — needs to know its own origin
53
+ cors({ origin: ??? })
54
+ ```
55
+
56
+ Most teams end up with a helper that grows over time:
57
+
58
+ ```typescript
59
+ // lib/url.ts — every team has one of these
60
+ function getBaseUrl() {
61
+ if (typeof window !== 'undefined') return ''
62
+ if (process.env.VERCEL_URL) return `https://${process.env.VERCEL_URL}`
63
+ return `http://localhost:${process.env.PORT ?? 3000}`
51
64
  }
65
+
66
+ // But wait — VERCEL_URL is the deployment URL, not your domain.
67
+ // And it doesn't work on the client. So you add more:
68
+ const baseUrl =
69
+ process.env.NEXT_PUBLIC_VERCEL_ENV === 'production'
70
+ ? `https://${process.env.NEXT_PUBLIC_VERCEL_PROJECT_PRODUCTION_URL}`
71
+ : process.env.NEXT_PUBLIC_VERCEL_URL
72
+ ? `https://${process.env.NEXT_PUBLIC_VERCEL_URL}`
73
+ : `http://localhost:${process.env.PORT ?? 3000}`
74
+
75
+ // And then Netlify uses different env vars. And Cloudflare uses different ones.
76
+ // And someone forgets the https://. And preview URLs break in production...
52
77
  ```
53
78
 
54
79
  ## How it works
55
80
 
56
- `which-url` reads environment variables that hosting providers set automatically. No configuration needed.
57
-
58
- **Resolution priority:**
81
+ Reads environment variables that hosting providers set automatically:
59
82
 
60
83
  1. `APP_URL` env var (your override — always wins)
61
- 2. Provider auto-detection
62
- 3. `window.location.origin` (browser)
63
- 4. `http://localhost:${PORT || 3000}` (development)
64
- 5. Throws in production if nothing detected
65
-
66
- ## Provider support
67
-
68
- | Provider | Detection | URL source |
69
- |----------|-----------|------------|
70
- | **Vercel** | `VERCEL` | `VERCEL_PROJECT_PRODUCTION_URL` / `VERCEL_BRANCH_URL` / `VERCEL_URL` |
71
- | **Netlify** | `NETLIFY` | `URL` / `DEPLOY_PRIME_URL` / `DEPLOY_URL` |
72
- | **Cloudflare Pages** | `CF_PAGES` | `CF_PAGES_URL` |
73
- | **Railway** | `RAILWAY_PUBLIC_DOMAIN` | `RAILWAY_PUBLIC_DOMAIN` |
74
- | **Fly.io** | `FLY_APP_NAME` | `{app}.fly.dev` |
75
- | **Render** | `RENDER` | `RENDER_EXTERNAL_URL` |
76
- | **DigitalOcean** | `DIGITALOCEAN_APP_PLATFORM` | `APP_URL` |
77
- | **Heroku** | `HEROKU_APP_NAME` | `{app}.herokuapp.com` |
84
+ 2. Provider auto-detection (Vercel, Netlify, etc.)
85
+ 3. `window.location.origin` (browser fallback)
86
+ 4. `http://localhost:${PORT || 3000}` (development fallback)
87
+
88
+ If nothing is detected in production, the singleton logs a warning and returns empty strings. Call `createUrl()` directly if you want it to throw instead.
78
89
 
79
90
  ## Override with `APP_URL`
80
91
 
81
- Set `APP_URL` to override auto-detection. Useful for custom domains, tunnels, or unsupported providers.
92
+ Set `APP_URL` when auto-detection isn't enough custom domains, tunnels, or unsupported providers:
82
93
 
83
94
  ```bash
84
95
  # .env.local
85
96
  APP_URL=https://myapp.com
86
97
  ```
87
98
 
88
- `NEXT_PUBLIC_APP_URL` also works (for client-side access in Next.js).
89
-
90
- ## Local development
99
+ Works with or without protocol (`APP_URL=myapp.com` `https://myapp.com`).
91
100
 
92
- Zero configauto-detects `http://localhost:3000` (or `PORT` if set).
101
+ **Client-side frameworks:** All framework prefixes are supported automatically `NEXT_PUBLIC_APP_URL`, `VITE_APP_URL`, `PUBLIC_APP_URL`, `NUXT_ENV_APP_URL`, etc.
93
102
 
94
- ```bash
95
- # Custom port
96
- APP_URL=http://localhost:4000
103
+ ## Platform support
97
104
 
98
- # Custom local domain
99
- APP_URL=http://myapp.local:3000
105
+ | Platform | Detection | URL source | Verified |
106
+ |----------|-----------|------------|:--------:|
107
+ | **Vercel** | `VERCEL` | `VERCEL_PROJECT_PRODUCTION_URL` / `VERCEL_BRANCH_URL` / `VERCEL_URL` | [x] |
108
+ | **Netlify** | `NETLIFY` | `URL` / `DEPLOY_PRIME_URL` / `DEPLOY_URL` | [ ] |
109
+ | **Cloudflare Pages** | `CF_PAGES` | `CF_PAGES_URL` | [ ] |
110
+ | **Railway** | `RAILWAY_PUBLIC_DOMAIN` | `RAILWAY_PUBLIC_DOMAIN` | [ ] |
111
+ | **Fly.io** | `FLY_APP_NAME` | `{app}.fly.dev` | [ ] |
112
+ | **Render** | `RENDER` | `RENDER_EXTERNAL_URL` | [ ] |
113
+ | **DigitalOcean** | `DIGITALOCEAN_APP_PLATFORM` | `APP_URL` | [ ] |
114
+ | **Heroku** | `HEROKU_APP_NAME` | `{app}.herokuapp.com` | [ ] |
100
115
 
101
- # Local HTTPS (mkcert)
102
- APP_URL=https://localhost:3000
116
+ On the client, Vercel's framework-prefixed env vars (`NEXT_PUBLIC_VERCEL_URL`, `VITE_VERCEL_URL`, etc.) are detected automatically.
103
117
 
104
- # Tunnel
105
- APP_URL=https://abc123.ngrok-free.app
106
- ```
118
+ **Help us verify:** If you're using one of these providers, [open an issue](https://github.com/manishrc/which-url/issues) with the output of `import appUrl from 'which-url'; console.log(appUrl)` from your deployment. We'll mark it as verified.
107
119
 
108
- For tunnels with dynamic URLs:
120
+ ## Examples
109
121
 
110
- ```bash
111
- APP_URL=$(curl -s localhost:4040/api/tunnels | jq -r '.tunnels[0].public_url') npm run dev
112
- ```
122
+ ```typescript
123
+ import { origin, hostname, isProduction } from 'which-url'
113
124
 
114
- ## Error handling
125
+ // Better Auth
126
+ betterAuth({ baseURL: origin })
115
127
 
116
- In **production**, `which-url` throws if it can't detect the URL — preventing silent misconfiguration (broken OAuth, CORS, emails pointing to localhost).
128
+ // API calls
129
+ fetch(`${origin}/api/data`)
117
130
 
118
- Use `createUrl` with a fallback to opt into lenient behavior:
131
+ // CORS
132
+ cors({ origin })
119
133
 
120
- ```typescript
121
- import { createUrl } from 'which-url'
134
+ // Cookies
135
+ cookie.domain = hostname
122
136
 
123
- const url = createUrl({ fallback: 'https://fallback.example.com' })
124
- url.href // never throws
137
+ // Environment checks
138
+ if (isProduction) {
139
+ enableAnalytics()
140
+ }
125
141
  ```
126
142
 
127
- In **development**, it always falls back to localhost.
128
-
129
143
  ## Gotchas
130
144
 
131
145
  ### Vercel: Redeploy after assigning a custom domain
132
146
 
133
147
  Framework-prefixed env vars like `NEXT_PUBLIC_VERCEL_PROJECT_PRODUCTION_URL` are inlined into the bundle at **build time** — the bundler replaces references with their literal values. If you assign a custom domain after deploying, the old deployment still has the previous URL baked in. Trigger a new deployment for the updated domain to take effect.
134
148
 
135
- ## Cloudflare Workers
149
+ ## Advanced
150
+
151
+ ### Tunnels (ngrok, Cloudflare Tunnel)
152
+
153
+ Tunnel URLs can't be auto-detected — they're external to the app process. Set `APP_URL`:
154
+
155
+ ```bash
156
+ APP_URL=https://abc123.ngrok-free.app npm run dev
157
+ ```
158
+
159
+ ### Cloudflare Workers
136
160
 
137
161
  Cloudflare Workers use runtime `env` bindings instead of `process.env`. Set `APP_URL` in `wrangler.toml`:
138
162
 
@@ -141,29 +165,15 @@ Cloudflare Workers use runtime `env` bindings instead of `process.env`. Set `APP
141
165
  APP_URL = "https://myapp.workers.dev"
142
166
  ```
143
167
 
144
- Modern wrangler polyfills `process.env` from `[vars]`, so `which-url` picks it up automatically. Cloudflare Pages build-time env vars also work.
145
-
146
- ## Integrations
168
+ Modern wrangler polyfills `process.env` from `[vars]`, so `which-url` picks it up automatically.
147
169
 
148
- ### Better Auth
170
+ ### Debugging
149
171
 
150
172
  ```typescript
151
- import appUrl from 'which-url'
152
- import { betterAuth } from 'better-auth'
173
+ import { debug } from 'which-url'
153
174
 
154
- export const auth = betterAuth({
155
- baseURL: appUrl.href,
156
- // ...
157
- })
158
- ```
159
-
160
- ### NextAuth / Auth.js
161
-
162
- ```typescript
163
- import appUrl from 'which-url'
164
-
165
- // No need to set NEXTAUTH_URL manually
166
- process.env.NEXTAUTH_URL = appUrl.href
175
+ console.log(debug)
176
+ // "platform=vercel | source=provider | url=https://myapp.com | env=production"
167
177
  ```
168
178
 
169
179
  ## API
@@ -174,30 +184,21 @@ An object with URL properties and environment helpers.
174
184
 
175
185
  ### Named exports
176
186
 
177
- | Export | Type | Description |
178
- |--------|------|-------------|
179
- | `href` | `string` | Full URL (`https://myapp.vercel.app`) |
180
- | `origin` | `string` | Origin (`https://myapp.vercel.app`) |
181
- | `hostname` | `string` | Hostname (`myapp.vercel.app`) |
182
- | `host` | `string` | Host with port (`myapp.vercel.app`) |
183
- | `protocol` | `string` | Protocol (`https:`) |
184
- | `port` | `string` | Port (empty if default) |
187
+ | Export | Type | Example |
188
+ |--------|------|---------|
189
+ | `origin` | `string` | `"https://myapp.vercel.app"` |
190
+ | `hostname` | `string` | `"myapp.vercel.app"` |
191
+ | `host` | `string` | `"myapp.vercel.app"` or `"localhost:3000"` |
192
+ | `href` | `string` | Same as `origin` |
193
+ | `protocol` | `string` | `"https:"` |
194
+ | `port` | `string` | `""` or `"3000"` |
185
195
  | `env` | `AppEnv` | `"production"` \| `"preview"` \| `"local"` |
186
- | `isProduction` | `boolean` | `true` if production |
187
- | `isPreview` | `boolean` | `true` if preview/staging |
188
- | `isLocal` | `boolean` | `true` if local development |
189
- | `createUrl(options?)` | `function` | Create a new instance with custom options |
190
-
191
- ### `createUrl(options?)`
192
-
193
- ```typescript
194
- createUrl({ fallback?: string }): WhichUrl
195
- ```
196
-
197
- Re-resolves the URL from current environment. Use for:
198
- - Custom fallbacks (never throws)
199
- - Re-resolution in tests
200
- - Dynamic configuration
196
+ | `platform` | `Platform` | `"vercel"` \| `"netlify"` \| ... \| `null` |
197
+ | `source` | `Source` | `"override"` \| `"provider"` \| `"browser"` \| `"fallback"` \| `null` |
198
+ | `debug` | `string` | `"platform=vercel \| source=provider \| url=https://myapp.com \| env=production"` |
199
+ | `isProduction` | `boolean` | |
200
+ | `isPreview` | `boolean` | |
201
+ | `isLocal` | `boolean` | |
201
202
 
202
203
  ## License
203
204
 
package/dist/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
- import type { WhichUrl, AppEnv, CreateUrlOptions } from "./types";
2
- export declare function createUrl(options?: CreateUrlOptions): WhichUrl;
1
+ import type { WhichUrl, AppEnv, Platform, Source } from "./types";
3
2
  declare let _resolved: WhichUrl;
4
3
  export declare const href: string;
5
4
  export declare const origin: string;
@@ -8,9 +7,12 @@ export declare const host: string;
8
7
  export declare const protocol: string;
9
8
  export declare const port: string;
10
9
  export declare const env: AppEnv;
10
+ export declare const platform: Platform;
11
+ export declare const source: Source;
12
+ export declare const debug: string;
11
13
  export declare const isProduction: boolean;
12
14
  export declare const isPreview: boolean;
13
15
  export declare const isLocal: boolean;
14
16
  export default _resolved;
15
- export type { WhichUrl, AppEnv, CreateUrlOptions };
17
+ export type { WhichUrl, AppEnv, Platform, Source };
16
18
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAEjE,wBAAgB,SAAS,CAAC,OAAO,CAAC,EAAE,gBAAgB,GAAG,QAAQ,CAgB9D;AAGD,QAAA,IAAI,SAAS,EAAE,QAAQ,CAAA;AAsBvB,eAAO,MAAM,IAAI,EAAE,MAAuB,CAAA;AAC1C,eAAO,MAAM,MAAM,EAAE,MAAyB,CAAA;AAC9C,eAAO,MAAM,QAAQ,EAAE,MAA2B,CAAA;AAClD,eAAO,MAAM,IAAI,EAAE,MAAuB,CAAA;AAC1C,eAAO,MAAM,QAAQ,EAAE,MAA2B,CAAA;AAClD,eAAO,MAAM,IAAI,EAAE,MAAuB,CAAA;AAC1C,eAAO,MAAM,GAAG,EAAE,MAAsB,CAAA;AACxC,eAAO,MAAM,YAAY,EAAE,OAAgC,CAAA;AAC3D,eAAO,MAAM,SAAS,EAAE,OAA6B,CAAA;AACrD,eAAO,MAAM,OAAO,EAAE,OAA2B,CAAA;AAGjD,eAAe,SAAS,CAAA;AAExB,YAAY,EAAE,QAAQ,EAAE,MAAM,EAAE,gBAAgB,EAAE,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AA0BjE,QAAA,IAAI,SAAS,EAAE,QAAQ,CAAA;AAyBvB,eAAO,MAAM,IAAI,EAAE,MAAuB,CAAA;AAC1C,eAAO,MAAM,MAAM,EAAE,MAAyB,CAAA;AAC9C,eAAO,MAAM,QAAQ,EAAE,MAA2B,CAAA;AAClD,eAAO,MAAM,IAAI,EAAE,MAAuB,CAAA;AAC1C,eAAO,MAAM,QAAQ,EAAE,MAA2B,CAAA;AAClD,eAAO,MAAM,IAAI,EAAE,MAAuB,CAAA;AAC1C,eAAO,MAAM,GAAG,EAAE,MAAsB,CAAA;AACxC,eAAO,MAAM,QAAQ,EAAE,QAA6B,CAAA;AACpD,eAAO,MAAM,MAAM,EAAE,MAAyB,CAAA;AAC9C,eAAO,MAAM,KAAK,EAAE,MAAwB,CAAA;AAC5C,eAAO,MAAM,YAAY,EAAE,OAAgC,CAAA;AAC3D,eAAO,MAAM,SAAS,EAAE,OAA6B,CAAA;AACrD,eAAO,MAAM,OAAO,EAAE,OAA2B,CAAA;AAGjD,eAAe,SAAS,CAAA;AAExB,YAAY,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAA"}
package/dist/index.js CHANGED
@@ -144,31 +144,37 @@ function normalizeUrl(raw) {
144
144
  }
145
145
 
146
146
  // src/resolve.ts
147
- function resolveUrl(options) {
147
+ function resolveUrl() {
148
148
  const env = getEnv();
149
149
  const override = getVar(env, "APP_URL");
150
150
  if (override)
151
- return normalizeUrl(override);
151
+ return { url: normalizeUrl(override), source: "override" };
152
152
  for (const p of providers) {
153
153
  if (p.detect(env)) {
154
154
  const url = p.resolveUrl(env);
155
155
  if (url)
156
- return normalizeUrl(url);
156
+ return { url: normalizeUrl(url), source: "provider" };
157
157
  }
158
158
  }
159
159
  if (typeof window !== "undefined" && window.location) {
160
- return window.location.origin;
160
+ return { url: window.location.origin, source: "browser" };
161
161
  }
162
162
  const isProduction = env.NODE_ENV === "production";
163
163
  if (!isProduction) {
164
164
  const port = env.PORT || "3000";
165
- return `http://localhost:${port}`;
166
- }
167
- if (options?.fallback) {
168
- return normalizeUrl(options.fallback);
165
+ return { url: `http://localhost:${port}`, source: "fallback" };
169
166
  }
170
167
  throw new Error("which-url: Cannot detect app URL. Set APP_URL environment variable.");
171
168
  }
169
+ function resolvePlatform() {
170
+ const env = getEnv();
171
+ for (const p of providers) {
172
+ if (p.detect(env)) {
173
+ return p.name;
174
+ }
175
+ }
176
+ return null;
177
+ }
172
178
 
173
179
  // src/env.ts
174
180
  var validEnvs = ["production", "preview", "local"];
@@ -191,10 +197,12 @@ function resolveEnv() {
191
197
  }
192
198
 
193
199
  // src/index.ts
194
- function createUrl(options) {
195
- const resolved = resolveUrl(options);
196
- const parsed = new URL(resolved);
200
+ function resolve() {
201
+ const { url, source } = resolveUrl();
202
+ const parsed = new URL(url);
197
203
  const env = resolveEnv();
204
+ const platform = resolvePlatform();
205
+ const debug = `platform=${platform ?? "none"} | source=${source} | url=${parsed.origin} | env=${env}`;
198
206
  return {
199
207
  href: parsed.origin,
200
208
  origin: parsed.origin,
@@ -203,6 +211,9 @@ function createUrl(options) {
203
211
  protocol: parsed.protocol,
204
212
  port: parsed.port,
205
213
  env,
214
+ platform,
215
+ source,
216
+ debug,
206
217
  isProduction: env === "production",
207
218
  isPreview: env === "preview",
208
219
  isLocal: env === "local"
@@ -210,7 +221,7 @@ function createUrl(options) {
210
221
  }
211
222
  var _resolved;
212
223
  try {
213
- _resolved = createUrl();
224
+ _resolved = resolve();
214
225
  } catch (e) {
215
226
  console.warn(`[which-url] Could not detect app URL. Set APP_URL (e.g. APP_URL=https://myapp.com or APP_URL=myapp.com)`);
216
227
  _resolved = {
@@ -221,6 +232,9 @@ try {
221
232
  protocol: "",
222
233
  port: "",
223
234
  env: "local",
235
+ platform: null,
236
+ source: null,
237
+ debug: "platform=none | source=none | url=none | env=local",
224
238
  isProduction: false,
225
239
  isPreview: false,
226
240
  isLocal: true
@@ -233,13 +247,18 @@ var host = _resolved.host;
233
247
  var protocol = _resolved.protocol;
234
248
  var port = _resolved.port;
235
249
  var env = _resolved.env;
250
+ var platform = _resolved.platform;
251
+ var source = _resolved.source;
252
+ var debug = _resolved.debug;
236
253
  var isProduction = _resolved.isProduction;
237
254
  var isPreview = _resolved.isPreview;
238
255
  var isLocal = _resolved.isLocal;
239
256
  var src_default = _resolved;
240
257
  export {
258
+ source,
241
259
  protocol,
242
260
  port,
261
+ platform,
243
262
  origin,
244
263
  isProduction,
245
264
  isPreview,
@@ -249,5 +268,5 @@ export {
249
268
  host,
250
269
  env,
251
270
  src_default as default,
252
- createUrl
271
+ debug
253
272
  };
package/dist/resolve.d.ts CHANGED
@@ -1,3 +1,8 @@
1
- import type { CreateUrlOptions } from "./types";
2
- export declare function resolveUrl(options?: CreateUrlOptions): string;
1
+ import type { Platform, Source } from "./types";
2
+ export interface ResolveResult {
3
+ url: string;
4
+ source: Source;
5
+ }
6
+ export declare function resolveUrl(): ResolveResult;
7
+ export declare function resolvePlatform(): Platform;
3
8
  //# sourceMappingURL=resolve.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../src/resolve.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAE/C,wBAAgB,UAAU,CAAC,OAAO,CAAC,EAAE,gBAAgB,GAAG,MAAM,CAoC7D"}
1
+ {"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../src/resolve.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAE/C,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,MAAM,CAAA;IACX,MAAM,EAAE,MAAM,CAAA;CACf;AAED,wBAAgB,UAAU,IAAI,aAAa,CA+B1C;AAED,wBAAgB,eAAe,IAAI,QAAQ,CAQ1C"}
package/dist/types.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  export type AppEnv = "production" | "preview" | "local";
2
+ export type Platform = "vercel" | "netlify" | "cloudflare" | "railway" | "fly" | "render" | "digitalocean" | "heroku" | null;
3
+ export type Source = "override" | "provider" | "browser" | "fallback" | null;
2
4
  export interface WhichUrl {
3
5
  href: string;
4
6
  origin: string;
@@ -7,13 +9,13 @@ export interface WhichUrl {
7
9
  protocol: string;
8
10
  port: string;
9
11
  env: AppEnv;
12
+ platform: Platform;
13
+ source: Source;
14
+ debug: string;
10
15
  isProduction: boolean;
11
16
  isPreview: boolean;
12
17
  isLocal: boolean;
13
18
  }
14
- export interface CreateUrlOptions {
15
- fallback?: string;
16
- }
17
19
  export interface ProviderDetector {
18
20
  name: string;
19
21
  detect: (env: Record<string, string | undefined>) => boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,MAAM,GAAG,YAAY,GAAG,SAAS,GAAG,OAAO,CAAA;AAEvD,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,MAAM,CAAA;IACX,YAAY,EAAE,OAAO,CAAA;IACrB,SAAS,EAAE,OAAO,CAAA;IAClB,OAAO,EAAE,OAAO,CAAA;CACjB;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,KAAK,OAAO,CAAA;IAC5D,UAAU,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,KAAK,MAAM,GAAG,IAAI,CAAA;IACtE,UAAU,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,KAAK,MAAM,CAAA;CAChE"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,MAAM,GAAG,YAAY,GAAG,SAAS,GAAG,OAAO,CAAA;AAEvD,MAAM,MAAM,QAAQ,GAChB,QAAQ,GACR,SAAS,GACT,YAAY,GACZ,SAAS,GACT,KAAK,GACL,QAAQ,GACR,cAAc,GACd,QAAQ,GACR,IAAI,CAAA;AAER,MAAM,MAAM,MAAM,GAAG,UAAU,GAAG,UAAU,GAAG,SAAS,GAAG,UAAU,GAAG,IAAI,CAAA;AAE5E,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,MAAM,CAAA;IACX,QAAQ,EAAE,QAAQ,CAAA;IAClB,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;IACb,YAAY,EAAE,OAAO,CAAA;IACrB,SAAS,EAAE,OAAO,CAAA;IAClB,OAAO,EAAE,OAAO,CAAA;CACjB;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,KAAK,OAAO,CAAA;IAC5D,UAAU,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,KAAK,MAAM,GAAG,IAAI,CAAA;IACtE,UAAU,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,KAAK,MAAM,CAAA;CAChE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "which-url",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "description": "Auto-detect your app's URL across hosting providers. Zero config.",
5
5
  "type": "module",
6
6
  "exports": {