|
2 | 2 |
|
3 | 3 | const express = require('express'); |
4 | 4 | const path = require('path'); |
5 | | -const csrf = require('csurf'); |
6 | 5 | const Authentication = require('./Authentication.js'); |
7 | 6 | const fs = require('fs'); |
8 | 7 | const ConfigKeyCache = require('./configKeyCache.js'); |
@@ -201,7 +200,7 @@ module.exports = function(config, options) { |
201 | 200 | // Agent API endpoint for handling AI requests - scoped to specific app |
202 | 201 | app.post('/apps/:appId/agent', async (req, res) => { |
203 | 202 | try { |
204 | | - const { message, modelName, conversationId, permissions } = req.body; |
| 203 | + const { message, modelName, conversationId, permissions } = req.body || {}; |
205 | 204 | const { appId } = req.params; |
206 | 205 |
|
207 | 206 | if (!message || typeof message !== 'string' || message.trim() === '') { |
@@ -1065,7 +1064,7 @@ You have direct access to the Parse database through function calls, so you can |
1065 | 1064 | } |
1066 | 1065 | } |
1067 | 1066 |
|
1068 | | - app.get('/login', csrf(), function(req, res) { |
| 1067 | + app.get('/login', Authentication.csrfProtection, function(req, res) { |
1069 | 1068 | let redirectURL = null; |
1070 | 1069 | try { |
1071 | 1070 | const url = new URL(req.url, 'http://localhost'); |
@@ -1116,7 +1115,7 @@ You have direct access to the Parse database through function calls, so you can |
1116 | 1115 | }); |
1117 | 1116 |
|
1118 | 1117 | // For every other request, go to index.html. Let client-side handle the rest. |
1119 | | - app.get('/*', function(req, res) { |
| 1118 | + app.get('{*splat}', function(req, res) { |
1120 | 1119 | if (users && (!req.user || !req.user.isAuthenticated)) { |
1121 | 1120 | const redirect = req.url.replace('/login', ''); |
1122 | 1121 | if (redirect.length > 1) { |
|
0 commit comments