add nginx notes, sparrow update, fulcrum sync, servr.js

This commit is contained in:
openoms
2024-03-25 10:44:16 +01:00
parent df75eaa016
commit a6a64ea590
7 changed files with 242 additions and 10 deletions

34
proxy/server.js Normal file
View File

@@ -0,0 +1,34 @@
/*
# Install dependencies:
npm install express http-proxy-middleware
# Start with the command:
node server.js
*/
const express = require('express');
const { createProxyMiddleware } = require('http-proxy-middleware');
const app = express();
app.use('/api', createProxyMiddleware({
target: 'https://api.staging.galoy.io/graphql', // The target API endpoint
changeOrigin: true,
pathRewrite: {
'^/api': '', // Rewrite the API path, if needed
},
onProxyRes: function (proxyRes, req, res) {
// Add CORS headers to the response from the proxied server
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept, Authorization');
if (req.method === 'OPTIONS') {
// Preflight request, end it after setting headers
res.sendStatus(200);
}
},
}));
const PORT = 3000; // The port your proxy server will listen on
app.listen(PORT, () => {
console.log(`Proxy server is running on http://localhost:${PORT}`);
});