nitro-web 0.2.7 → 0.2.9
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.
|
@@ -13,6 +13,7 @@ import { isArray, pick, ucFirst, fullNameSplit, isEmail } from 'nitro-web/util'
|
|
|
13
13
|
|
|
14
14
|
const JWT_SECRET = process.env.JWT_SECRET || 'replace_this_with_secure_env_secret'
|
|
15
15
|
let authConfig = null
|
|
16
|
+
const resolveBaseUrlWarned = new Set()
|
|
16
17
|
const requiredConfigKeys = [...requiredEmailConfigKeys]
|
|
17
18
|
const optionalConfigKeys = [...optionalEmailConfigKeys, 'masterPassword', 'isNotMultiTenant', 'autoAddExistingUsers', 'limitOneTenantPerUser']
|
|
18
19
|
|
|
@@ -729,7 +730,7 @@ export async function tokenSend({ type, id, payload, beforeUpdate, beforeSendEma
|
|
|
729
730
|
}
|
|
730
731
|
|
|
731
732
|
export function getBaseUrl(req) {
|
|
732
|
-
return resolveBaseUrl(req?.
|
|
733
|
+
return resolveBaseUrl(req?.requestOrigin, authConfig.baseUrl)
|
|
733
734
|
}
|
|
734
735
|
|
|
735
736
|
export function resolveBaseUrl(reqUrl, cfgUrl) {
|
|
@@ -740,12 +741,22 @@ export function resolveBaseUrl(reqUrl, cfgUrl) {
|
|
|
740
741
|
const cfgHost = new URL(cfgUrl).hostname
|
|
741
742
|
const reqApex = getDomain(reqHost)
|
|
742
743
|
const cfgApex = getDomain(cfgHost)
|
|
744
|
+
const errorMessage = 'Nitro warning: auth.resolveBaseUrl: The request origin and the config baseUrl ' +
|
|
745
|
+
'are not the same apex domain. Defaulting to the Cfg baseUrl. Req:'
|
|
743
746
|
|
|
744
747
|
if (reqApex && cfgApex) {
|
|
748
|
+
if (reqApex !== cfgApex && !resolveBaseUrlWarned.has(reqHost)) {
|
|
749
|
+
resolveBaseUrlWarned.add(reqHost)
|
|
750
|
+
console.warn(errorMessage, reqApex, '!=', cfgApex)
|
|
751
|
+
}
|
|
745
752
|
return reqApex === cfgApex ? reqUrl : cfgUrl
|
|
746
753
|
} else if (reqHost === cfgHost || reqHost.endsWith('.' + cfgHost)) {
|
|
747
754
|
return reqUrl
|
|
748
755
|
} else {
|
|
756
|
+
if (!resolveBaseUrlWarned.has(reqHost)) {
|
|
757
|
+
resolveBaseUrlWarned.add(reqHost)
|
|
758
|
+
console.warn(errorMessage, reqHost, '!=', cfgHost)
|
|
759
|
+
}
|
|
749
760
|
return cfgUrl
|
|
750
761
|
}
|
|
751
762
|
} catch (_) {
|
|
@@ -82,7 +82,7 @@ async function billingPortalSessionCreate(req, res) {
|
|
|
82
82
|
}
|
|
83
83
|
const session = await stripe.billingPortal.sessions.create({
|
|
84
84
|
customer: req.user.stripeCustomer.id,
|
|
85
|
-
return_url: resolveBaseUrl(req.
|
|
85
|
+
return_url: resolveBaseUrl(req.requestOrigin, config.baseUrl) + '/subscriptions',
|
|
86
86
|
})
|
|
87
87
|
res.json(session.url)
|
|
88
88
|
} catch (err) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nitro-web",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.9",
|
|
4
4
|
"repository": "github:boycce/nitro-web",
|
|
5
5
|
"homepage": "https://boycce.github.io/nitro-web/",
|
|
6
6
|
"description": "Nitro is a battle-tested, modular base project to turbocharge your projects, styled using Tailwind 🚀",
|
package/server/router.js
CHANGED
|
@@ -333,7 +333,7 @@ export const middleware = {
|
|
|
333
333
|
// Handy boolean denoting that the request wants JSON returned
|
|
334
334
|
req.json = req.xhr || req.accepts(['html', 'json']) == 'json'
|
|
335
335
|
// Dynamic baseUrl from the request headers, may require app.set('trust proxy', 1) in the server setup for heroku proxying
|
|
336
|
-
req.
|
|
336
|
+
req.requestOrigin = req.protocol + '://' + req.headers.host
|
|
337
337
|
// log the headers if the config.logHeaders is true
|
|
338
338
|
if (configLocal.logHeaders) {
|
|
339
339
|
console.info('Headers:', req.headers)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.api.d.ts","sourceRoot":"","sources":["../../../components/auth/auth.api.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"auth.api.d.ts","sourceRoot":"","sources":["../../../components/auth/auth.api.js"],"names":[],"mappings":"AAqLA,qEAUC;AAED,qEAwEC;AAED,qEAGC;AAED,gEAMC;AAED,iEAgBC;AAED,oEAGC;AAED,oEA8BC;AAED,gEAgCC;AAID,qGAkDC;AAED;;;GAOC;AAED;;GAKC;AAID;;;;;;;;;GASG;AACH,8EAPG;IAA0B,QAAQ,GAA1B,MAAM;IACY,SAAS,GAA3B,MAAM;IACY,OAAO,GAAzB,MAAM;CACd,YAAQ,MAAM,+BACN,OAAO,GACL,OAAO,CAAC,MAAM,CAAC,CAqE3B;AAED,kFAiBC;AAED,mEAOC;AAED,+EAWC;AAED,sHAiBC;AAED;;;GAEC;AAED;;;GA0BC;AAED;;;;;;;;;GAmCC;AAED;;;;;;;;;;;;;;GAcG;AACH,mGAZG;IAAsD,IAAI,EAAlD,OAAO,GAAG,QAAQ,GAAG,eAAe;IACpB,EAAE,EAAlB,MAAM;IAKH,OAAO,EAJV;QACN,KAAK,EAAE,MAAM,CAAC;QACd,SAAS,EAAE,MAAM,CAAC;QACtB,CAAK,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACpB;IAC0B,YAAY;IACZ,eAAe;IACjB,OAAO,GAAxB,MAAM;CACd,GAAU,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,OAAO,CAAC,OAAO,CAAC,CAAA;CAAC,CAAC,CAmEtE;AAED,0CAEC;AAED,8DA6BC;AAED,gFAKC;;;;;;;;;;;;;;;;;;;;AAzuBD;;;;;;;;;;;;;;;EAiBC;AA0ED,0DAEC;AAgCD,mDAEC;AAtBD,iDAkBC;AA5BD,2DAQC;AA0BD,2DAwBC;AAtID,0EAsEC"}
|