@flamingo-stack/openframe-frontend-core 0.0.644 → 0.0.645
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 +2 -2
- package/dist/{chunk-FOSIR4QF.js → chunk-3DWDJ54N.js} +5 -5
- package/dist/{chunk-CBXZSTAG.cjs → chunk-3J7YNAYI.cjs} +973 -793
- package/dist/chunk-3J7YNAYI.cjs.map +1 -0
- package/dist/{chunk-3DGRXC74.js → chunk-3PGYHT67.js} +5 -5
- package/dist/{chunk-YB6FI2G3.js → chunk-3SMLYVM2.js} +1 -1
- package/dist/{chunk-YB6FI2G3.js.map → chunk-3SMLYVM2.js.map} +1 -1
- package/dist/{chunk-DCCY54LU.cjs → chunk-46G4WFA7.cjs} +14 -14
- package/dist/{chunk-DCCY54LU.cjs.map → chunk-46G4WFA7.cjs.map} +1 -1
- package/dist/{chunk-OMSUWB6A.cjs → chunk-4A4DQSTI.cjs} +118 -118
- package/dist/{chunk-OMSUWB6A.cjs.map → chunk-4A4DQSTI.cjs.map} +1 -1
- package/dist/{chunk-4EEUB62O.js → chunk-4HVWGYHI.js} +2 -2
- package/dist/{chunk-UKV52KAP.cjs → chunk-56FDKQ7R.cjs} +44 -44
- package/dist/{chunk-UKV52KAP.cjs.map → chunk-56FDKQ7R.cjs.map} +1 -1
- package/dist/{chunk-G5U4JP45.js → chunk-5ONM3FHQ.js} +4 -4
- package/dist/{chunk-PFV4DAX5.js → chunk-6PMUA6JW.js} +10 -10
- package/dist/{chunk-GELNUDBT.cjs → chunk-77BLJHKI.cjs} +10 -10
- package/dist/{chunk-GELNUDBT.cjs.map → chunk-77BLJHKI.cjs.map} +1 -1
- package/dist/{chunk-KJWPAJRT.js → chunk-7EI3NES7.js} +3 -3
- package/dist/{chunk-3IXDZI3R.cjs → chunk-DOVVKQMZ.cjs} +3 -3
- package/dist/{chunk-3IXDZI3R.cjs.map → chunk-DOVVKQMZ.cjs.map} +1 -1
- package/dist/{chunk-KOQCA5X5.cjs → chunk-DWJREJRA.cjs} +5 -5
- package/dist/{chunk-KOQCA5X5.cjs.map → chunk-DWJREJRA.cjs.map} +1 -1
- package/dist/{chunk-S2KMNFFN.js → chunk-EI3SLIWL.js} +7 -7
- package/dist/{chunk-7R2DIGG4.cjs → chunk-EX5PJGVA.cjs} +76 -76
- package/dist/{chunk-7R2DIGG4.cjs.map → chunk-EX5PJGVA.cjs.map} +1 -1
- package/dist/{chunk-GBEUGDZG.cjs → chunk-F6U2H42L.cjs} +23 -23
- package/dist/{chunk-GBEUGDZG.cjs.map → chunk-F6U2H42L.cjs.map} +1 -1
- package/dist/{chunk-KEKN76JR.js → chunk-FRQ2DE5Z.js} +5 -5
- package/dist/{chunk-3UBT2OIX.cjs → chunk-GPZ6Q2NP.cjs} +74 -74
- package/dist/{chunk-3UBT2OIX.cjs.map → chunk-GPZ6Q2NP.cjs.map} +1 -1
- package/dist/{chunk-JOV64HW5.js → chunk-GRBZC5N3.js} +3 -3
- package/dist/{chunk-CHIHYC7Q.cjs → chunk-GSD62VAY.cjs} +21 -21
- package/dist/{chunk-CHIHYC7Q.cjs.map → chunk-GSD62VAY.cjs.map} +1 -1
- package/dist/{chunk-UEXIMEVU.js → chunk-GSNX2GDA.js} +10 -10
- package/dist/{chunk-LPMDCQLL.js → chunk-H3EJDISW.js} +2 -2
- package/dist/{chunk-RNMGKAS6.js → chunk-HDCIDJSP.js} +15 -15
- package/dist/{chunk-7Q5XXPCB.js → chunk-HHE7UNGR.js} +14 -14
- package/dist/{chunk-KOLVBEW5.js → chunk-IWISVG4P.js} +3 -3
- package/dist/{chunk-GNKM6R55.cjs → chunk-JH5P72AF.cjs} +25 -25
- package/dist/{chunk-GNKM6R55.cjs.map → chunk-JH5P72AF.cjs.map} +1 -1
- package/dist/{chunk-LCK7T2RM.cjs → chunk-JU6SBF3C.cjs} +13 -13
- package/dist/{chunk-LCK7T2RM.cjs.map → chunk-JU6SBF3C.cjs.map} +1 -1
- package/dist/{chunk-27RD5XTP.js → chunk-JZVSQT2V.js} +5 -5
- package/dist/{chunk-F2KBCLUG.js → chunk-KKSSA4CS.js} +2 -2
- package/dist/{chunk-MRIOYSXH.js → chunk-KYIOOOQY.js} +5 -5
- package/dist/{chunk-FKBM6U43.js → chunk-LZLT67PE.js} +2 -2
- package/dist/{chunk-LZYPSDFE.cjs → chunk-M2MTAES4.cjs} +90 -90
- package/dist/{chunk-LZYPSDFE.cjs.map → chunk-M2MTAES4.cjs.map} +1 -1
- package/dist/{chunk-B3Z3RJRW.js → chunk-M4AD2PHE.js} +5 -5
- package/dist/{chunk-BVQEU5JB.js → chunk-MT5A25AX.js} +2 -2
- package/dist/{chunk-TTVOBWAH.js → chunk-MTC6DWVH.js} +5 -5
- package/dist/{chunk-OVXYX47B.cjs → chunk-N4Q5GKBN.cjs} +19 -19
- package/dist/{chunk-OVXYX47B.cjs.map → chunk-N4Q5GKBN.cjs.map} +1 -1
- package/dist/{chunk-FAD5WURS.cjs → chunk-OGBM3JPR.cjs} +124 -124
- package/dist/{chunk-FAD5WURS.cjs.map → chunk-OGBM3JPR.cjs.map} +1 -1
- package/dist/chunk-OXB6LRBK.js +20 -0
- package/dist/chunk-OXB6LRBK.js.map +1 -0
- package/dist/{chunk-TGUA3C4U.cjs → chunk-Q7XUKTBB.cjs} +9 -9
- package/dist/{chunk-TGUA3C4U.cjs.map → chunk-Q7XUKTBB.cjs.map} +1 -1
- package/dist/{chunk-RFFF2EYD.cjs → chunk-QXML4X4W.cjs} +15 -15
- package/dist/{chunk-RFFF2EYD.cjs.map → chunk-QXML4X4W.cjs.map} +1 -1
- package/dist/{chunk-HOGOQA2X.js → chunk-R3CH2ASE.js} +3 -3
- package/dist/{chunk-SKABQX44.js → chunk-RUC2V3VH.js} +7 -7
- package/dist/{chunk-MCQAOIUK.cjs → chunk-SID5YPKF.cjs} +37 -37
- package/dist/{chunk-MCQAOIUK.cjs.map → chunk-SID5YPKF.cjs.map} +1 -1
- package/dist/{chunk-HPWLIYRL.js → chunk-T36DLNMO.js} +14 -14
- package/dist/{chunk-UPKZU6QU.cjs → chunk-U2YLMFJK.cjs} +1 -1
- package/dist/{chunk-UPKZU6QU.cjs.map → chunk-U2YLMFJK.cjs.map} +1 -1
- package/dist/{chunk-B5IFXCRF.cjs → chunk-UF7AUQ3M.cjs} +41 -41
- package/dist/{chunk-B5IFXCRF.cjs.map → chunk-UF7AUQ3M.cjs.map} +1 -1
- package/dist/{chunk-IXD6SHQ6.js → chunk-ULJNU46H.js} +6 -6
- package/dist/{chunk-CCWI3622.cjs → chunk-VTYP25OW.cjs} +4 -4
- package/dist/{chunk-CCWI3622.cjs.map → chunk-VTYP25OW.cjs.map} +1 -1
- package/dist/{chunk-C5Y5T6GC.cjs → chunk-WIYSHSNU.cjs} +20 -20
- package/dist/{chunk-C5Y5T6GC.cjs.map → chunk-WIYSHSNU.cjs.map} +1 -1
- package/dist/{chunk-T3C3JLGV.cjs → chunk-WKX7DYFM.cjs} +8 -8
- package/dist/{chunk-T3C3JLGV.cjs.map → chunk-WKX7DYFM.cjs.map} +1 -1
- package/dist/{chunk-4WVWRFGP.js → chunk-WSRGTWQL.js} +9 -9
- package/dist/chunk-X7CEWD6V.cjs +20 -0
- package/dist/chunk-X7CEWD6V.cjs.map +1 -0
- package/dist/{chunk-I57XLISO.js → chunk-X7LGHPH5.js} +195 -15
- package/dist/chunk-X7LGHPH5.js.map +1 -0
- package/dist/{chunk-5JUTGEZE.js → chunk-XBTZOO74.js} +2 -2
- package/dist/{chunk-RWURXICE.cjs → chunk-XGD6SCHN.cjs} +44 -44
- package/dist/{chunk-RWURXICE.cjs.map → chunk-XGD6SCHN.cjs.map} +1 -1
- package/dist/{chunk-RB6L5EGM.cjs → chunk-XILTWY3L.cjs} +1131 -1131
- package/dist/{chunk-RB6L5EGM.cjs.map → chunk-XILTWY3L.cjs.map} +1 -1
- package/dist/{chunk-EHAYNUOL.cjs → chunk-XOGD2AME.cjs} +3 -3
- package/dist/{chunk-EHAYNUOL.cjs.map → chunk-XOGD2AME.cjs.map} +1 -1
- package/dist/{chunk-IIXB5REN.cjs → chunk-YEXV52L5.cjs} +16 -16
- package/dist/{chunk-IIXB5REN.cjs.map → chunk-YEXV52L5.cjs.map} +1 -1
- package/dist/{chunk-65EVGKFV.cjs → chunk-YQZXCJQL.cjs} +14 -14
- package/dist/{chunk-65EVGKFV.cjs.map → chunk-YQZXCJQL.cjs.map} +1 -1
- package/dist/{chunk-N6HNK25A.cjs → chunk-YWUZL3RT.cjs} +11 -11
- package/dist/{chunk-N6HNK25A.cjs.map → chunk-YWUZL3RT.cjs.map} +1 -1
- package/dist/{chunk-VE52MSYC.js → chunk-Z7UIO5RQ.js} +8 -8
- package/dist/components/calendar.cjs +10 -10
- package/dist/components/calendar.js +2 -2
- package/dist/components/case-studies/index.cjs +30 -30
- package/dist/components/case-studies/index.js +14 -14
- package/dist/components/chat/embeddable-chat.d.ts +1 -1
- package/dist/components/chat/index.cjs +9 -9
- package/dist/components/chat/index.js +8 -8
- package/dist/components/chat/utils/source-row-cta.d.ts +1 -1
- package/dist/components/command.d.ts +7 -7
- package/dist/components/contact/index.cjs +15 -15
- package/dist/components/contact/index.js +14 -14
- package/dist/components/docs/index.cjs +18 -18
- package/dist/components/docs/index.js +17 -17
- package/dist/components/embeds/index.cjs +15 -15
- package/dist/components/embeds/index.js +14 -14
- package/dist/components/faq/index.cjs +16 -16
- package/dist/components/faq/index.js +15 -15
- package/dist/components/features/index.cjs +14 -14
- package/dist/components/features/index.js +13 -13
- package/dist/components/help-center-pages/index.cjs +37 -37
- package/dist/components/help-center-pages/index.js +28 -28
- package/dist/components/icons/index.cjs +3 -3
- package/dist/components/icons/index.js +2 -2
- package/dist/components/index.cjs +115 -115
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.js +31 -31
- package/dist/components/index.js.map +1 -1
- package/dist/components/meeting-scheduler/index.cjs +119 -119
- package/dist/components/meeting-scheduler/index.js +15 -15
- package/dist/components/navigation/index.cjs +17 -17
- package/dist/components/navigation/index.js +16 -16
- package/dist/components/onboarding-guides/index.cjs +18 -18
- package/dist/components/onboarding-guides/index.js +17 -17
- package/dist/components/related-content/index.cjs +10 -10
- package/dist/components/related-content/index.js +9 -9
- package/dist/components/resizable.d.ts +1 -1
- package/dist/components/tickets/index.cjs +19 -19
- package/dist/components/tickets/index.js +18 -18
- package/dist/components/ui/file-manager/index.cjs +57 -57
- package/dist/components/ui/file-manager/index.js +4 -4
- package/dist/components/ui/index.cjs +14 -14
- package/dist/components/ui/index.js +13 -13
- package/dist/contexts/chat-runtime-context.d.ts +1 -1
- package/dist/contexts/index.cjs +2 -2
- package/dist/contexts/index.js +1 -1
- package/dist/hooks/index.cjs +7 -7
- package/dist/hooks/index.js +6 -6
- package/dist/index.cjs +36 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +30 -22
- package/dist/index.js.map +1 -1
- package/dist/platform-domains.cjs +43 -0
- package/dist/platform-domains.cjs.map +1 -1
- package/dist/platform-domains.d.ts +62 -4
- package/dist/platform-domains.d.ts.map +1 -1
- package/dist/platform-domains.js +39 -1
- package/dist/platform-domains.js.map +1 -1
- package/dist/types/index.cjs +0 -104
- package/dist/types/index.cjs.map +1 -1
- package/dist/types/index.js +0 -104
- package/dist/types/index.js.map +1 -1
- package/dist/utils/cn.d.ts +0 -21
- package/dist/utils/cn.d.ts.map +1 -1
- package/dist/utils/index.cjs +53 -25
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.d.ts +1 -2
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +49 -25
- package/dist/utils/index.js.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/platform-domains.test.ts +124 -0
- package/src/components/chat/embeddable-chat.tsx +2 -2
- package/src/components/chat/utils/__tests__/source-row-cta.test.ts +2 -2
- package/src/components/chat/utils/source-row-cta.ts +4 -4
- package/src/components/made-with-love.tsx +2 -2
- package/src/contexts/chat-runtime-context.tsx +1 -1
- package/src/platform-domains.ts +99 -4
- package/src/utils/.cn.md +3 -23
- package/src/utils/cn.ts +0 -47
- package/src/utils/index.ts +9 -2
- package/dist/chunk-23V5BSHD.cjs +0 -169
- package/dist/chunk-23V5BSHD.cjs.map +0 -1
- package/dist/chunk-CBXZSTAG.cjs.map +0 -1
- package/dist/chunk-I57XLISO.js.map +0 -1
- package/dist/chunk-O4MCCKKN.js +0 -169
- package/dist/chunk-O4MCCKKN.js.map +0 -1
- /package/dist/{chunk-FOSIR4QF.js.map → chunk-3DWDJ54N.js.map} +0 -0
- /package/dist/{chunk-3DGRXC74.js.map → chunk-3PGYHT67.js.map} +0 -0
- /package/dist/{chunk-4EEUB62O.js.map → chunk-4HVWGYHI.js.map} +0 -0
- /package/dist/{chunk-G5U4JP45.js.map → chunk-5ONM3FHQ.js.map} +0 -0
- /package/dist/{chunk-PFV4DAX5.js.map → chunk-6PMUA6JW.js.map} +0 -0
- /package/dist/{chunk-KJWPAJRT.js.map → chunk-7EI3NES7.js.map} +0 -0
- /package/dist/{chunk-S2KMNFFN.js.map → chunk-EI3SLIWL.js.map} +0 -0
- /package/dist/{chunk-KEKN76JR.js.map → chunk-FRQ2DE5Z.js.map} +0 -0
- /package/dist/{chunk-JOV64HW5.js.map → chunk-GRBZC5N3.js.map} +0 -0
- /package/dist/{chunk-UEXIMEVU.js.map → chunk-GSNX2GDA.js.map} +0 -0
- /package/dist/{chunk-LPMDCQLL.js.map → chunk-H3EJDISW.js.map} +0 -0
- /package/dist/{chunk-RNMGKAS6.js.map → chunk-HDCIDJSP.js.map} +0 -0
- /package/dist/{chunk-7Q5XXPCB.js.map → chunk-HHE7UNGR.js.map} +0 -0
- /package/dist/{chunk-KOLVBEW5.js.map → chunk-IWISVG4P.js.map} +0 -0
- /package/dist/{chunk-27RD5XTP.js.map → chunk-JZVSQT2V.js.map} +0 -0
- /package/dist/{chunk-F2KBCLUG.js.map → chunk-KKSSA4CS.js.map} +0 -0
- /package/dist/{chunk-MRIOYSXH.js.map → chunk-KYIOOOQY.js.map} +0 -0
- /package/dist/{chunk-FKBM6U43.js.map → chunk-LZLT67PE.js.map} +0 -0
- /package/dist/{chunk-B3Z3RJRW.js.map → chunk-M4AD2PHE.js.map} +0 -0
- /package/dist/{chunk-BVQEU5JB.js.map → chunk-MT5A25AX.js.map} +0 -0
- /package/dist/{chunk-TTVOBWAH.js.map → chunk-MTC6DWVH.js.map} +0 -0
- /package/dist/{chunk-HOGOQA2X.js.map → chunk-R3CH2ASE.js.map} +0 -0
- /package/dist/{chunk-SKABQX44.js.map → chunk-RUC2V3VH.js.map} +0 -0
- /package/dist/{chunk-HPWLIYRL.js.map → chunk-T36DLNMO.js.map} +0 -0
- /package/dist/{chunk-IXD6SHQ6.js.map → chunk-ULJNU46H.js.map} +0 -0
- /package/dist/{chunk-4WVWRFGP.js.map → chunk-WSRGTWQL.js.map} +0 -0
- /package/dist/{chunk-5JUTGEZE.js.map → chunk-XBTZOO74.js.map} +0 -0
- /package/dist/{chunk-VE52MSYC.js.map → chunk-Z7UIO5RQ.js.map} +0 -0
package/package.json
CHANGED
|
@@ -3,6 +3,11 @@ import {
|
|
|
3
3
|
PLATFORM_DOMAINS,
|
|
4
4
|
byKey,
|
|
5
5
|
getPlatformProductionUrl,
|
|
6
|
+
getPlatformUrl,
|
|
7
|
+
getDeploymentUrl,
|
|
8
|
+
getRequestOrigin,
|
|
9
|
+
isLocalUrl,
|
|
10
|
+
resolveRedirectTarget,
|
|
6
11
|
getPlatformByHostname,
|
|
7
12
|
getAllPlatformBaseDomains,
|
|
8
13
|
hostOf,
|
|
@@ -156,6 +161,125 @@ describe('env override path', () => {
|
|
|
156
161
|
});
|
|
157
162
|
});
|
|
158
163
|
|
|
164
|
+
describe('getPlatformUrl — the one platform-URL resolver', () => {
|
|
165
|
+
it('is the registry URL in a production build, with no trailing slash', () => {
|
|
166
|
+
vi.stubEnv('NODE_ENV', 'production');
|
|
167
|
+
expect(getPlatformUrl('flamingo')).toBe('https://www.flamingo.run');
|
|
168
|
+
expect(getPlatformUrl('openframe')).toBe(getPlatformProductionUrl('openframe').replace(/\/+$/, ''));
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
it("never reads Vercel's first-listed domain", () => {
|
|
172
|
+
vi.stubEnv('NODE_ENV', 'production');
|
|
173
|
+
vi.stubEnv('VERCEL_PROJECT_PRODUCTION_URL', 'flamingo.cx');
|
|
174
|
+
expect(getPlatformUrl('flamingo')).toBe('https://www.flamingo.run');
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
it('is the local dev URL outside a production build, unless production is asked for', () => {
|
|
178
|
+
vi.stubEnv('NODE_ENV', 'development');
|
|
179
|
+
vi.stubEnv('NEXT_PUBLIC_DEV_URL', '');
|
|
180
|
+
expect(getPlatformUrl('openmsp')).toBe('http://localhost:3000');
|
|
181
|
+
expect(getPlatformUrl('openmsp', { environment: 'production' })).toBe('https://www.openmsp.ai');
|
|
182
|
+
vi.stubEnv('NEXT_PUBLIC_DEV_URL', 'https://my-tunnel.example/');
|
|
183
|
+
expect(getPlatformUrl('openmsp')).toBe('https://my-tunnel.example');
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
describe('getDeploymentUrl — the one app-origin resolver', () => {
|
|
188
|
+
// Server-side cases: jsdom defines `window`, which is the browser branch.
|
|
189
|
+
const onServer = () => vi.stubGlobal('window', undefined);
|
|
190
|
+
|
|
191
|
+
it("is a Vercel preview's own immutable URL", () => {
|
|
192
|
+
onServer();
|
|
193
|
+
vi.stubEnv('VERCEL_ENV', 'preview');
|
|
194
|
+
vi.stubEnv('VERCEL_URL', 'flamingo-abc123-flamingocx.vercel.app');
|
|
195
|
+
expect(getDeploymentUrl({ platform: 'flamingo' })).toBe('https://flamingo-abc123-flamingocx.vercel.app');
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
it("is the platform's registry URL in production, whatever Vercel's first domain is", () => {
|
|
199
|
+
onServer();
|
|
200
|
+
vi.stubEnv('VERCEL_ENV', 'production');
|
|
201
|
+
vi.stubEnv('VERCEL_PROJECT_PRODUCTION_URL', 'flamingo.cx');
|
|
202
|
+
expect(getDeploymentUrl({ platform: 'flamingo' })).toBe('https://www.flamingo.run');
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
it('uses a runtime-configured app URL (a self-hosted install) over every default', () => {
|
|
206
|
+
onServer();
|
|
207
|
+
vi.stubEnv('VERCEL_ENV', 'production');
|
|
208
|
+
expect(getDeploymentUrl({ platform: 'openframe-dashboard', configuredUrl: 'frame.acme-msp.example/' })).toBe(
|
|
209
|
+
'https://frame.acme-msp.example',
|
|
210
|
+
);
|
|
211
|
+
expect(getDeploymentUrl({ platform: 'openframe-dashboard', configuredUrl: ' ' })).toBe(
|
|
212
|
+
getPlatformUrl('openframe-dashboard', { environment: 'production' }),
|
|
213
|
+
);
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
it('is localhost on the running port in development', () => {
|
|
217
|
+
onServer();
|
|
218
|
+
vi.stubEnv('VERCEL_ENV', '');
|
|
219
|
+
vi.stubEnv('NODE_ENV', 'development');
|
|
220
|
+
vi.stubEnv('NEXT_PUBLIC_DEV_URL', '');
|
|
221
|
+
vi.stubEnv('PORT', '4000');
|
|
222
|
+
expect(getDeploymentUrl({ platform: 'openframe-dashboard' })).toBe('http://localhost:4000');
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
it("is the page's origin in the browser", () => {
|
|
226
|
+
vi.stubGlobal('window', { location: { origin: 'https://tenant.openframe.ai' } });
|
|
227
|
+
expect(getDeploymentUrl({ platform: 'openframe-dashboard', configuredUrl: 'https://ignored.example' })).toBe(
|
|
228
|
+
'https://tenant.openframe.ai',
|
|
229
|
+
);
|
|
230
|
+
});
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
describe('getRequestOrigin / isLocalUrl / resolveRedirectTarget', () => {
|
|
234
|
+
const headers = (values: Record<string, string>) => ({ get: (name: string) => values[name] ?? null });
|
|
235
|
+
|
|
236
|
+
it('reads the host the request arrived on, https unless local, ignoring x-forwarded-host, else the app origin', () => {
|
|
237
|
+
expect(getRequestOrigin(headers({ host: 'www.flamingo.run' }), { platform: 'flamingo' })).toBe(
|
|
238
|
+
'https://www.flamingo.run',
|
|
239
|
+
);
|
|
240
|
+
expect(getRequestOrigin(headers({ host: 'localhost:3000' }), { platform: 'flamingo' })).toBe(
|
|
241
|
+
'http://localhost:3000',
|
|
242
|
+
);
|
|
243
|
+
expect(getRequestOrigin(headers({ host: '[::1]:3000' }), { platform: 'flamingo' })).toBe('http://[::1]:3000');
|
|
244
|
+
expect(
|
|
245
|
+
getRequestOrigin(headers({ host: 'x.vercel.app', 'x-forwarded-proto': 'https' }), { platform: 'flamingo' }),
|
|
246
|
+
).toBe('https://x.vercel.app');
|
|
247
|
+
expect(
|
|
248
|
+
getRequestOrigin(headers({ host: 'www.flamingo.run', 'x-forwarded-host': 'evil.example' }), {
|
|
249
|
+
platform: 'flamingo',
|
|
250
|
+
}),
|
|
251
|
+
).toBe('https://www.flamingo.run');
|
|
252
|
+
vi.stubGlobal('window', undefined);
|
|
253
|
+
vi.stubEnv('NEXT_PUBLIC_DEV_URL', 'http://localhost:4000');
|
|
254
|
+
expect(getRequestOrigin(headers({}), { platform: 'flamingo' })).toBe('http://localhost:4000');
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
it.each([
|
|
258
|
+
['http://localhost:3000', true],
|
|
259
|
+
['http://127.0.0.1:3000/x', true],
|
|
260
|
+
['http://0.0.0.0', true],
|
|
261
|
+
['http://[::1]:3000', true],
|
|
262
|
+
['https://www.flamingo.run', false],
|
|
263
|
+
['https://localhost.example.com', false],
|
|
264
|
+
['http://127.evil.example', false],
|
|
265
|
+
['not a url', false],
|
|
266
|
+
])('isLocalUrl(%s) → %s', (url, local) => expect(isLocalUrl(url)).toBe(local));
|
|
267
|
+
|
|
268
|
+
it('resolves same-origin paths and passes explicit absolute URLs through', () => {
|
|
269
|
+
const origin = 'https://flamingo-abc123-flamingocx.vercel.app';
|
|
270
|
+
expect(resolveRedirectTarget(origin, '/admin/x?y=1').href).toBe(`${origin}/admin/x?y=1`);
|
|
271
|
+
expect(resolveRedirectTarget(origin, 'auth/callback-client').href).toBe(`${origin}/auth/callback-client`);
|
|
272
|
+
expect(resolveRedirectTarget(origin, 'https://www.flamingo.run/blog').href).toBe('https://www.flamingo.run/blog');
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
it.each(['//evil.example/path', '/\\evil.example/path', '\\\\evil.example', '\\/evil.example'])(
|
|
276
|
+
'refuses %s, which would leave the origin',
|
|
277
|
+
target => {
|
|
278
|
+
expect(() => resolveRedirectTarget('https://www.flamingo.run', target)).toThrow('is not a same-origin path');
|
|
279
|
+
},
|
|
280
|
+
);
|
|
281
|
+
});
|
|
282
|
+
|
|
159
283
|
describe('registry integrity', () => {
|
|
160
284
|
it('byKey resolves every key and openframe-dashboard is pseudo', () => {
|
|
161
285
|
expect(byKey('openframe-dashboard')?.pseudo).toBe(true);
|
|
@@ -154,7 +154,7 @@ export interface EmbeddableChatProps {
|
|
|
154
154
|
baseRoute?: string;
|
|
155
155
|
/** When the embedder doesn't host a `[...path]` route to render markdown
|
|
156
156
|
* chips against, set this to a platform that does. Chips with
|
|
157
|
-
* `externalUrl: null` resolve to `
|
|
157
|
+
* `externalUrl: null` resolve to `getPlatformUrl(chipBasePlatform) +
|
|
158
158
|
* '/knowledge-base/' + path` and open in a new tab. */
|
|
159
159
|
chipBasePlatform?: string;
|
|
160
160
|
/** DB-driven list of enabled RAG table ids (chip catalog filter).
|
|
@@ -1439,7 +1439,7 @@ function EmbeddableChatInner({
|
|
|
1439
1439
|
// doesn't host an in-app doc viewer should NOT pass an empty baseRoute (that just
|
|
1440
1440
|
// falls back to the platform default here) — instead it sets a truthy baseRoute +
|
|
1441
1441
|
// `chipBasePlatform` so doc chips with no externalUrl resolve cross-platform to that
|
|
1442
|
-
// platform's public knowledge hub (`
|
|
1442
|
+
// platform's public knowledge hub (`getPlatformUrl(chipBasePlatform)/knowledge-base/…`),
|
|
1443
1443
|
// exactly like the hub's openframe config (baseRoute:'/', chipBasePlatform:'openframe').
|
|
1444
1444
|
const resolvedBaseRoute = baseRoute || (source === 'flamingo' ? '/knowledge-base' : '/data-room');
|
|
1445
1445
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import {
|
|
2
|
+
import { getPlatformUrl } from '../../../../platform-domains';
|
|
3
3
|
import { resolveSourceRowCTA } from '../source-row-cta';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -28,7 +28,7 @@ describe('resolveSourceRowCTA — doc-chip platform routing', () => {
|
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
const expectHref = (platform: string, base: string, path: string) =>
|
|
31
|
-
new URL(path, `${
|
|
31
|
+
new URL(path, `${getPlatformUrl(platform)}/${base}/`).toString();
|
|
32
32
|
|
|
33
33
|
it('routes EACH doc source to its own platform from ONE shared context (mixed sources)', () => {
|
|
34
34
|
const md = resolveSourceRowCTA(markdownRow, { docPlatformTargets });
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
|
|
24
24
|
import { FileText } from 'lucide-react';
|
|
25
25
|
import type React from 'react';
|
|
26
|
-
import {
|
|
26
|
+
import { getPlatformUrl } from '../../../platform-domains';
|
|
27
27
|
import type { ComposeContentUrl } from '../../../utils/content-href';
|
|
28
28
|
import { canonicalContentRefType } from '../../../utils/list-url';
|
|
29
29
|
import type { ChatRef } from '../chat-ref.types';
|
|
@@ -93,7 +93,7 @@ export interface SourceRowContext {
|
|
|
93
93
|
* replacement for the single `chipBasePlatform`. Maps a doc-table documentType
|
|
94
94
|
* (`'markdown'`, `'data_room_doc'`, …) → the platform whose PUBLIC doc viewer
|
|
95
95
|
* hosts it + that viewer's base path. A doc chip with no `externalUrl` resolves
|
|
96
|
-
* to `
|
|
96
|
+
* to `getPlatformUrl(platform)/<basePath>/<path>` PER ROW — so a chat mixing several
|
|
97
97
|
* doc sources sends EACH to its own home (markdown→flamingo/knowledge-base,
|
|
98
98
|
* data_room_doc→company-hub/data-room) instead of one static fallback for all.
|
|
99
99
|
* Wins over `chipBasePlatform` when a row's documentType has an entry.
|
|
@@ -212,11 +212,11 @@ export function resolveSourceRowCTA(row: SourceRowInput, ctx: SourceRowContext =
|
|
|
212
212
|
// slash-stripping regex `/^\/+|\/+$/g` tripped CodeQL's js/polynomial-redos (high)
|
|
213
213
|
// since `\/+$` backtracks on inputs with many '/'. split/filter/join is linear.
|
|
214
214
|
const seg = docTarget.basePath.split('/').filter(Boolean).join('/');
|
|
215
|
-
const base = `${
|
|
215
|
+
const base = `${getPlatformUrl(docTarget.platform)}${seg ? `/${seg}` : ''}/`;
|
|
216
216
|
href = safeHref(new URL(safePath, base).toString()) ?? null;
|
|
217
217
|
targetPlatform = docTarget.platform;
|
|
218
218
|
} else if (ctx.chipBasePlatform) {
|
|
219
|
-
const base = `${
|
|
219
|
+
const base = `${getPlatformUrl(ctx.chipBasePlatform)}/knowledge-base/`;
|
|
220
220
|
href = safeHref(new URL(safePath, base).toString()) ?? null;
|
|
221
221
|
targetPlatform = ctx.chipBasePlatform;
|
|
222
222
|
} else if (ctx.baseRoute) {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import type React from 'react';
|
|
4
4
|
import { useState, useEffect } from 'react';
|
|
5
|
-
import {
|
|
5
|
+
import { getPlatformUrl } from '../platform-domains';
|
|
6
6
|
import { FlamingoLogo } from './flamingo-logo';
|
|
7
7
|
|
|
8
8
|
interface MadeWithLoveProps {
|
|
@@ -52,7 +52,7 @@ export function MadeWithLove({ className = '', size = 'md', showOnMobile = true
|
|
|
52
52
|
};
|
|
53
53
|
|
|
54
54
|
const config = sizeConfig[size];
|
|
55
|
-
const flamingoUrl =
|
|
55
|
+
const flamingoUrl = getPlatformUrl('flamingo');
|
|
56
56
|
|
|
57
57
|
// Container styles using primitive CSS
|
|
58
58
|
const containerStyle: React.CSSProperties = {
|
|
@@ -246,7 +246,7 @@ export interface ChatRuntime {
|
|
|
246
246
|
* the single `chipBasePlatform` prop. Maps a doc-table documentType
|
|
247
247
|
* (`'markdown'`, `'data_room_doc'`, …) → `{ platform, basePath }` for the PUBLIC
|
|
248
248
|
* doc viewer that hosts it. Doc chips with no `externalUrl` resolve PER ROW to
|
|
249
|
-
* `
|
|
249
|
+
* `getPlatformUrl(platform)/<basePath>/<path>`, so a chat mixing several doc sources
|
|
250
250
|
* sends EACH to its own home (markdown→flamingo/knowledge-base,
|
|
251
251
|
* data_room_doc→company-hub/data-room) instead of one static fallback. The hub
|
|
252
252
|
* may keep using `chipBasePlatform` (one doc source per platform); embedders that
|
package/src/platform-domains.ts
CHANGED
|
@@ -115,9 +115,8 @@ function envOverrideFor(key: string): string | null {
|
|
|
115
115
|
* base-domain derivation, CSP) receives a parseable URL. Full-URL inputs (the registry
|
|
116
116
|
* `defaultUrl`s, any scheme'd override) pass through unchanged.
|
|
117
117
|
*
|
|
118
|
-
* EXPORTED as the single owner of the scheme-normalization rule
|
|
119
|
-
*
|
|
120
|
-
* graph and cannot import this — see the comment there).
|
|
118
|
+
* EXPORTED as the single owner of the scheme-normalization rule. This subpath is pure ESM,
|
|
119
|
+
* so a consumer's next.config.mjs imports it directly rather than keeping a copy.
|
|
121
120
|
*
|
|
122
121
|
* Handles a (theoretical) protocol-relative `//host` too: strips the leading slashes so it
|
|
123
122
|
* doesn't become `https:////host` (empty-host → hostOf null → silent platform drop).
|
|
@@ -133,7 +132,7 @@ export function ensureScheme(url: string): string {
|
|
|
133
132
|
* NEVER throws / undefined — the default guarantees a host (this is what keeps the
|
|
134
133
|
* cookie base-domains, the reverse map, and CSP intact even with every override unset).
|
|
135
134
|
* The result ALWAYS carries a scheme (`ensureScheme`), so the scheme-less env overrides
|
|
136
|
-
* resolve to valid URLs. Unknown-key fallback
|
|
135
|
+
* resolve to valid URLs. Unknown-key fallback is flamingo's URL.
|
|
137
136
|
*/
|
|
138
137
|
export function getPlatformProductionUrl(platform: string): string {
|
|
139
138
|
const resolved =
|
|
@@ -141,6 +140,102 @@ export function getPlatformProductionUrl(platform: string): string {
|
|
|
141
140
|
return ensureScheme(resolved);
|
|
142
141
|
}
|
|
143
142
|
|
|
143
|
+
/**
|
|
144
|
+
* THE URL of a platform, for the environment the code is running in, no trailing slash.
|
|
145
|
+
* The one platform-URL resolver: consumers build every link to a platform from this.
|
|
146
|
+
*
|
|
147
|
+
* - `environment: 'current'` (default): the local dev URL (`NEXT_PUBLIC_DEV_URL`, else
|
|
148
|
+
* `http://localhost:3000`) outside a production build, the registry's production URL
|
|
149
|
+
* in any production build (a preview included — a preview never links to itself as
|
|
150
|
+
* canonical).
|
|
151
|
+
* - `environment: 'production'`: the registry's production URL everywhere, for links that
|
|
152
|
+
* leave the machine.
|
|
153
|
+
*
|
|
154
|
+
* `platform` is REQUIRED. The former `getBaseUrl()` accepted none and then returned
|
|
155
|
+
* `VERCEL_PROJECT_PRODUCTION_URL` — whichever domain Vercel lists first for a project
|
|
156
|
+
* (`flamingo.cx` on flamingo, a 308), and production on previews. A deployment's own
|
|
157
|
+
* origin is not a platform URL; consumers resolve it themselves.
|
|
158
|
+
*/
|
|
159
|
+
export function getPlatformUrl(platform: string, options: { environment?: 'current' | 'production' } = {}): string {
|
|
160
|
+
const url =
|
|
161
|
+
options.environment !== 'production' && process.env.NODE_ENV !== 'production'
|
|
162
|
+
? process.env.NEXT_PUBLIC_DEV_URL || 'http://localhost:3000'
|
|
163
|
+
: getPlatformProductionUrl(platform);
|
|
164
|
+
return url.replace(/\/+$/, '');
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Where THIS app is reachable, no trailing slash: what anything outside the app must
|
|
169
|
+
* fetch from the code that is running (rendered images, provider callbacks, self-calls).
|
|
170
|
+
* The one app-origin resolver; each app only supplies its own platform and config.
|
|
171
|
+
*
|
|
172
|
+
* In order:
|
|
173
|
+
* 1. In the browser: the page's origin.
|
|
174
|
+
* 2. `configuredUrl`: an app whose URL is configured at runtime (a self-hosted OpenFrame
|
|
175
|
+
* install's `NEXT_PUBLIC_APP_URL`) — that install's address wins over any default.
|
|
176
|
+
* 3. On a Vercel preview: the deployment's immutable `VERCEL_URL` (not the branch alias,
|
|
177
|
+
* which moves to the next commit and would serve other code).
|
|
178
|
+
* 4. In any production build: the platform's registry URL.
|
|
179
|
+
* 5. In development: `NEXT_PUBLIC_DEV_URL`, else localhost on the running port.
|
|
180
|
+
*/
|
|
181
|
+
export function getDeploymentUrl(options: { platform: string; configuredUrl?: string | null }): string {
|
|
182
|
+
if (typeof window !== 'undefined') return window.location.origin;
|
|
183
|
+
const configured = options.configuredUrl?.trim();
|
|
184
|
+
if (configured) return ensureScheme(configured).replace(/\/+$/, '');
|
|
185
|
+
if (process.env.VERCEL_ENV === 'preview' && process.env.VERCEL_URL) {
|
|
186
|
+
return ensureScheme(process.env.VERCEL_URL).replace(/\/+$/, '');
|
|
187
|
+
}
|
|
188
|
+
if (process.env.VERCEL_ENV === 'production' || process.env.NODE_ENV === 'production') {
|
|
189
|
+
return getPlatformUrl(options.platform, { environment: 'production' });
|
|
190
|
+
}
|
|
191
|
+
return (process.env.NEXT_PUBLIC_DEV_URL || `http://localhost:${process.env.PORT ?? 3000}`).replace(/\/+$/, '');
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/** A hostname on the local machine, matched WHOLE: `localhost.example.com` and
|
|
195
|
+
* `127.evil.example` are public hosts. */
|
|
196
|
+
const LOCAL_HOSTNAME = /^(localhost|127(?:\.\d{1,3}){3}|0\.0\.0\.0|\[::1\])$/i;
|
|
197
|
+
|
|
198
|
+
/** Is this URL on the local machine, where no external system (a webhook sender, an
|
|
199
|
+
* OAuth provider) can reach it? False for anything that is not a URL. */
|
|
200
|
+
export function isLocalUrl(url: string): boolean {
|
|
201
|
+
try {
|
|
202
|
+
return LOCAL_HOSTNAME.test(new URL(url).hostname);
|
|
203
|
+
} catch {
|
|
204
|
+
return false;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* The origin a server request arrived on, from its `host` header only (what the edge set
|
|
210
|
+
* for this request — a client-writable `x-forwarded-host` never chooses where a flow
|
|
211
|
+
* returns). `http` for a local host unless the proxy says otherwise, else `https`.
|
|
212
|
+
* With no Host header, the app's own origin (`getDeploymentUrl` for `platform`).
|
|
213
|
+
*/
|
|
214
|
+
export function getRequestOrigin(
|
|
215
|
+
headers: { get(name: string): string | null },
|
|
216
|
+
options: { platform: string; configuredUrl?: string | null },
|
|
217
|
+
): string {
|
|
218
|
+
const host = headers.get('host');
|
|
219
|
+
if (!host) return getDeploymentUrl(options);
|
|
220
|
+
const local = LOCAL_HOSTNAME.test(host.replace(/:\d+$/, ''));
|
|
221
|
+
const proto = headers.get('x-forwarded-proto')?.split(',')[0].trim() || (local ? 'http' : 'https');
|
|
222
|
+
return `${proto}://${host}`;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Where a redirect goes: a path resolves against `origin`; an explicit absolute
|
|
227
|
+
* `http(s)://` URL is used as is. THROWS when a relative target resolves to another
|
|
228
|
+
* origin (`//evil.example`, `/\\evil.example`), so a shared redirect helper built on it
|
|
229
|
+
* can never be an open redirect.
|
|
230
|
+
*/
|
|
231
|
+
export function resolveRedirectTarget(origin: string, target: string): URL {
|
|
232
|
+
const url = new URL(target, origin);
|
|
233
|
+
if (!/^https?:\/\//i.test(target) && url.origin !== new URL(origin).origin) {
|
|
234
|
+
throw new Error(`resolveRedirectTarget: "${target}" is not a same-origin path`);
|
|
235
|
+
}
|
|
236
|
+
return url;
|
|
237
|
+
}
|
|
238
|
+
|
|
144
239
|
// ── Single-owner host primitives ──
|
|
145
240
|
|
|
146
241
|
/** Canonical URL→host parser: `.hostname` (PORT-STRIPPED, lowercased), null on parse failure. */
|
package/src/utils/.cn.md
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
<!-- source-hash: 700d6c65ebfb65630e665b437acf4e83 -->
|
|
2
|
-
Utility module providing
|
|
2
|
+
Utility module providing a Tailwind-aware class name merger (`cn`) that correctly handles custom ODS typography utilities. (Platform URLs are resolved by `getPlatformUrl` in `platform-domains.ts`, not here.)
|
|
3
3
|
|
|
4
4
|
## Key Components
|
|
5
5
|
|
|
6
6
|
| Export | Type | Description |
|
|
7
7
|
|--------|------|-------------|
|
|
8
8
|
| `cn` | `function` | Combines class names using `clsx` + a custom `tailwind-merge` instance |
|
|
9
|
-
| `getBaseUrl` | `function` | Returns the application base URL for the current environment |
|
|
10
9
|
| `twMerge` | internal | Extended `tailwind-merge` instance with the `ods-typography` class group |
|
|
11
10
|
|
|
12
11
|
### `ods-typography` Class Group
|
|
@@ -22,7 +21,7 @@ Without this registration, `cn('text-badge', 'text-ods-text-on-accent')` would d
|
|
|
22
21
|
## Usage Example
|
|
23
22
|
|
|
24
23
|
```typescript
|
|
25
|
-
import { cn
|
|
24
|
+
import { cn } from '@/lib/cn'
|
|
26
25
|
|
|
27
26
|
// Merge conditional classes safely — typography and colour both survive
|
|
28
27
|
const className = cn(
|
|
@@ -31,25 +30,6 @@ const className = cn(
|
|
|
31
30
|
isActive && 'bg-accent',
|
|
32
31
|
)
|
|
33
32
|
|
|
34
|
-
// Current deployment URL (dev → localhost, prod → Vercel/canonical domain)
|
|
35
|
-
const currentUrl = getBaseUrl()
|
|
36
|
-
|
|
37
|
-
// Specific platform URL (respects env override, falls back to canonical)
|
|
38
|
-
const flamingoUrl = getBaseUrl('flamingo') // https://www.flamingo.run
|
|
39
|
-
const openMspUrl = getBaseUrl('openmsp') // https://www.openmsp.ai
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
## `getBaseUrl` Resolution Order
|
|
43
|
-
|
|
44
|
-
```mermaid
|
|
45
|
-
graph TD
|
|
46
|
-
A[getBaseUrl called] --> B{NODE_ENV !== production?}
|
|
47
|
-
B -->|Yes| C[NEXT_PUBLIC_DEV_URL or localhost:3000]
|
|
48
|
-
B -->|No| D{platform arg provided?}
|
|
49
|
-
D -->|Yes| E[getPlatformProductionUrl from SSOT]
|
|
50
|
-
D -->|No| F{VERCEL_PROJECT_PRODUCTION_URL set?}
|
|
51
|
-
F -->|Yes| G[https://vercel-domain]
|
|
52
|
-
F -->|No| H[getPlatformProductionUrl via NEXT_PUBLIC_APP_TYPE]
|
|
53
33
|
```
|
|
54
34
|
|
|
55
|
-
> Platform canonical URLs and their `NEXT_PUBLIC_*_URL`
|
|
35
|
+
> Platform URLs are resolved by `getPlatformUrl` (with the canonical URLs and their `NEXT_PUBLIC_*_URL` overrides) exclusively in [`src/platform-domains.ts`](https://github.com/flamingo-stack/openframe-oss-lib/blob/main/src/platform-domains.ts).
|
package/src/utils/cn.ts
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import { clsx, type ClassValue } from 'clsx';
|
|
2
2
|
import { extendTailwindMerge } from 'tailwind-merge';
|
|
3
|
-
// Platform→domain resolution moved to the SSOT module `src/platform-domains.ts`.
|
|
4
|
-
// `getPlatformProductionUrl` / `getAllPlatformBaseDomains` now live there (re-exported
|
|
5
|
-
// via the utils barrel for existing callers); `getBaseUrl` stays here because it owns the
|
|
6
|
-
// dev-localhost + Vercel-self-origin branches, and delegates its platform branch.
|
|
7
|
-
import { getPlatformProductionUrl } from '../platform-domains';
|
|
8
3
|
|
|
9
4
|
/**
|
|
10
5
|
* EVERY custom `text-*` utility we add in `tailwind.config.ts` MUST be listed here.
|
|
@@ -37,45 +32,3 @@ const twMerge = extendTailwindMerge<'ods-typography'>({
|
|
|
37
32
|
export function cn(...inputs: ClassValue[]) {
|
|
38
33
|
return twMerge(clsx(inputs));
|
|
39
34
|
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Get the application base URL for the current environment
|
|
43
|
-
*
|
|
44
|
-
* @param platform - Optional platform name (openmsp, flamingo, tmcg, openframe, etc.)
|
|
45
|
-
* @returns The base URL with protocol (https:// or http://)
|
|
46
|
-
*
|
|
47
|
-
* Priority order:
|
|
48
|
-
* 1. Development (http://localhost:3000)
|
|
49
|
-
* 2. Platform-specific URL via the SSOT (if `platform` provided) — env override ?? default
|
|
50
|
-
* 3. VERCEL_PROJECT_PRODUCTION_URL (Vercel production domain)
|
|
51
|
-
* 4. Production fallback: the DEPLOYING platform's canonical URL (NEXT_PUBLIC_APP_TYPE),
|
|
52
|
-
* openmsp if unset — sourced from the SSOT, no hardcoded literal.
|
|
53
|
-
*
|
|
54
|
-
* The per-platform canonical URLs + their `NEXT_PUBLIC_*_URL` overrides are the single
|
|
55
|
-
* source of truth in `src/platform-domains.ts` (`PLATFORM_DOMAINS`).
|
|
56
|
-
*
|
|
57
|
-
* @example
|
|
58
|
-
* getBaseUrl() // Current deployment's URL
|
|
59
|
-
* getBaseUrl('flamingo') // https://www.flamingo.run (prod) or http://localhost:3000 (dev)
|
|
60
|
-
*/
|
|
61
|
-
export function getBaseUrl(platform?: string): string {
|
|
62
|
-
// In development, always use localhost (regardless of platform)
|
|
63
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
64
|
-
return process.env.NEXT_PUBLIC_DEV_URL || 'http://localhost:3000';
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// If platform is specified, return its production URL (env override ?? default)
|
|
68
|
-
if (platform) {
|
|
69
|
-
return getPlatformProductionUrl(platform);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// Production: Use Vercel domain if available
|
|
73
|
-
if (process.env.VERCEL_PROJECT_PRODUCTION_URL) {
|
|
74
|
-
return `https://${process.env.VERCEL_PROJECT_PRODUCTION_URL}`;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// Production fallback: the deploying platform's canonical www domain (avoids Google
|
|
78
|
-
// "Page with redirect"). Derived from the SSOT for the current app type (openmsp when
|
|
79
|
-
// unset → 'https://www.openmsp.ai', byte-identical to the old hardcoded fallback).
|
|
80
|
-
return getPlatformProductionUrl(process.env.NEXT_PUBLIC_APP_TYPE || 'openmsp');
|
|
81
|
-
}
|
package/src/utils/index.ts
CHANGED
|
@@ -4,7 +4,15 @@ export { cn } from './cn';
|
|
|
4
4
|
// here so existing `/utils` callers keep working; the new resolver/helpers
|
|
5
5
|
// (getPlatformByHostname/hostOf/expandWwwApex/…) are exposed via the `/platform-domains`
|
|
6
6
|
// subpath ONLY (one import surface for the new API).
|
|
7
|
-
export {
|
|
7
|
+
export {
|
|
8
|
+
getPlatformUrl,
|
|
9
|
+
getPlatformProductionUrl,
|
|
10
|
+
getAllPlatformBaseDomains,
|
|
11
|
+
getDeploymentUrl,
|
|
12
|
+
getRequestOrigin,
|
|
13
|
+
isLocalUrl,
|
|
14
|
+
resolveRedirectTarget,
|
|
15
|
+
} from '../platform-domains';
|
|
8
16
|
// Number / currency / byte / date formatters live in `./format` (single
|
|
9
17
|
// source of truth). Re-exported here so existing callers that pull from
|
|
10
18
|
// the barrel keep working without changing imports.
|
|
@@ -40,7 +48,6 @@ export {
|
|
|
40
48
|
pick,
|
|
41
49
|
NO_CLIENT_CACHE,
|
|
42
50
|
} from './common';
|
|
43
|
-
export { getBaseUrl } from '../utils/cn';
|
|
44
51
|
// SEO title length budget — server-safe constant (SSOT). Consumed by the hub
|
|
45
52
|
// (prompt guidance + DB check value) and by SEOEditorPreview (input maxLength).
|
|
46
53
|
export { SEO_TITLE_MAX_LENGTH } from './seo-title';
|