mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Merge pull request #1423 from bdashore3/staging
Fix the CORS proxy again
This commit is contained in:
@@ -302,6 +302,8 @@ app.use(function (req, res, next) {
|
||||
});
|
||||
|
||||
if (getConfigValue('enableCorsProxy', false) === true || cliArguments.corsProxy === true) {
|
||||
const bodyParser = require('body-parser');
|
||||
app.use(bodyParser.json());
|
||||
console.log('Enabling CORS proxy');
|
||||
|
||||
app.use('/proxy/:url(*)', async (req, res) => {
|
||||
@@ -332,7 +334,10 @@ if (getConfigValue('enableCorsProxy', false) === true || cliArguments.corsProxy
|
||||
body: bodyMethods.includes(req.method) ? JSON.stringify(req.body) : undefined,
|
||||
});
|
||||
|
||||
response.body.pipe(res); // pipe the response to the proxy response
|
||||
// Copy over relevant response params to the proxy response
|
||||
res.statusCode = response.status;
|
||||
res.statusMessage = response.statusText;
|
||||
response.body.pipe(res);
|
||||
|
||||
} catch (error) {
|
||||
res.status(500).send('Error occurred while trying to proxy to: ' + url + ' ' + error);
|
||||
|
||||
Reference in New Issue
Block a user