Load Turnstile site key at runtime
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 54s

This commit is contained in:
Cauê Faleiros
2026-07-28 13:03:51 -03:00
parent 20dde11ff0
commit ed3a3f0571
9 changed files with 77 additions and 25 deletions

View File

@@ -8,5 +8,6 @@ module.exports = {
JWT_SECRET: process.env.JWT_SECRET || 'super_secret_jwt_key_123',
DATABASE_URL: process.env.DATABASE_URL || 'postgres://graphuser:graphpassword@localhost:5432/graphdb',
N8N_WHATSAPP_TRIGGER_URL: process.env.N8N_WHATSAPP_TRIGGER_URL || 'http://localhost:5678/webhook/whatsapp',
TURNSTILE_SITE_KEY: process.env.TURNSTILE_SITE_KEY || process.env.VITE_TURNSTILE_SITE_KEY || '',
TURNSTILE_SECRET: process.env.TURNSTILE_SECRET || process.env.TURNSTILE_SECRET_KEY || ''
};

View File

@@ -1,6 +1,6 @@
const express = require('express');
const { login } = require('../auth');
const { TURNSTILE_SECRET } = require('../config');
const { TURNSTILE_SECRET, TURNSTILE_SITE_KEY } = require('../config');
const router = express.Router();
const TURNSTILE_VERIFY_URL = 'https://challenges.cloudflare.com/turnstile/v0/siteverify';
@@ -34,6 +34,13 @@ const verifyCaptcha = async (captchaToken, remoteIp) => {
}
};
router.get('/login/config', (req, res) => {
res.json({
captchaRequired: Boolean(TURNSTILE_SECRET),
turnstileSiteKey: TURNSTILE_SITE_KEY
});
});
router.post('/login', async (req, res, next) => {
const { email, password, captchaToken } = req.body;