Fill out the quick form below to secure your spin on the prize wheel!
useProxy to true and proxyUrl to your server URL in the script configuration.
// server.js (Node/Express) - store your GHL API key in .env as GHL_API_KEY
// Install: npm install express node-fetch dotenv
require('dotenv').config();
const express = require('express');
const fetch = require('node-fetch'); // Node 18+ has fetch built-in
const app = express();
app.use(express.json());
// Enable simple CORS for your frontend origin (adjust in production)
app.use((req, res, next) => {
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Headers', 'Content-Type');
if (req.method === 'OPTIONS') return res.sendStatus(204);
next();
});
app.post('/ghl-proxy', async (req, res) => {
const { firstName, phone, email } = req.body || {};
// Basic validation
if (!phone) return res.status(400).json({ error: 'phone is required' });
try {
const resp = await fetch('https://api.gohighlevel.com/v1/contacts/', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${process.env.GHL_API_KEY}`
},
body: JSON.stringify({ firstName, phone, email })
});
const text = await resp.text();
if (!resp.ok) return res.status(resp.status).send(text);
try { return res.json(JSON.parse(text)); } catch (e) { return res.send(text); }
} catch (err) {
console.error('Proxy error', err);
return res.status(500).json({ error: 'proxy error' });
}
});
const PORT = process.env.PORT || 3000;
app.listen(PORT, () => console.log('GHL proxy listening on', PORT));