Route BASE_URL through env module to prevent callback URL drift #14
1 changed files with 3 additions and 3 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
import { instrument } from 'succinct-async'
|
import { instrument } from 'succinct-async'
|
||||||
import express, { Request, Response, NextFunction } from 'express'
|
import express, { Request, Response, NextFunction } from 'express'
|
||||||
import rateLimit from 'express-rate-limit'
|
import rateLimit from 'express-rate-limit'
|
||||||
import { appSigner, BRAND_NAME, BRAND_ACCENT, BRAND_LOGO, EVENT_VIEWER_URL, CORS_ORIGIN } from './env.js'
|
import { appSigner, BASE_URL, BRAND_NAME, BRAND_ACCENT, BRAND_LOGO, EVENT_VIEWER_URL, CORS_ORIGIN } from './env.js'
|
||||||
import { render } from './templates.js'
|
import { render } from './templates.js'
|
||||||
import { confirmSubscriptionAction, unsubscribeAction, registerSubscription, ActionError } from './actions.js'
|
import { confirmSubscriptionAction, unsubscribeAction, registerSubscription, ActionError } from './actions.js'
|
||||||
import { getSubscriptionById, insertEvent, getSubscriptionByKey, getSubscriptionByPubkey } from './database.js'
|
import { getSubscriptionById, insertEvent, getSubscriptionByKey, getSubscriptionByPubkey } from './database.js'
|
||||||
|
|
@ -172,7 +172,7 @@ addRoute('get', '/subscription/email', async (req: Request, res: Response) => {
|
||||||
return res.status(404).json({ error: 'Subscription not found' })
|
return res.status(404).json({ error: 'Subscription not found' })
|
||||||
}
|
}
|
||||||
|
|
||||||
const callback = `${process.env.BASE_URL}/notify/${sub.id}`
|
const callback = `${BASE_URL}/notify/${sub.id}`
|
||||||
|
|
||||||
res.json({
|
res.json({
|
||||||
key: sub.key,
|
key: sub.key,
|
||||||
|
|
@ -214,7 +214,7 @@ addRoute('put', '/subscription/email', async (req: Request, res: Response) => {
|
||||||
// Look up the actual subscription key from the DB
|
// Look up the actual subscription key from the DB
|
||||||
const sub = await getSubscriptionByPubkey(pubkey)
|
const sub = await getSubscriptionByPubkey(pubkey)
|
||||||
if (sub) {
|
if (sub) {
|
||||||
const callback = `${process.env.BASE_URL}/notify/${sub.id}`
|
const callback = `${BASE_URL}/notify/${sub.id}`
|
||||||
res.json({ key: sub.key, callback })
|
res.json({ key: sub.key, callback })
|
||||||
} else {
|
} else {
|
||||||
console.error('Failed to register subscription:', error)
|
console.error('Failed to register subscription:', error)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue