Skip to content

Instantly share code, notes, and snippets.

@dougwithseismic
Last active September 1, 2022 13:21
Show Gist options
  • Save dougwithseismic/b8c03ddc6b80b49abc4675048a2f6d2e to your computer and use it in GitHub Desktop.
Save dougwithseismic/b8c03ddc6b80b49abc4675048a2f6d2e to your computer and use it in GitHub Desktop.
JavaScript Express / Node : How can I serve different scripts to different customers like Hotjar does?
<script defer src='https://my.backend.io/v1/library/customer-xyz123/ />
app.get('/v1/library/:uid', async (req, res) => {
const customerId = req.params.uid
const settings = await getSettings(customerId) // { name : 'doug', features: [1, 2 ,5] ... }
res.sendFile('./libary.js') // How can I take ./library.js as a template, and add customer-xyz123's settings to the script?
}
const settings = { name : 'doug', features: [1, 2 ,5] ... }
doStuff(settings)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment