@opengis/fastify-table 1.4.57 → 1.4.58

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +13 -0
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -4,6 +4,7 @@ import { existsSync, readdirSync, readFileSync } from 'node:fs';
4
4
  import { fileURLToPath } from 'node:url';
5
5
 
6
6
  import fp from 'fastify-plugin';
7
+ import proxy from '@fastify/http-proxy';
7
8
 
8
9
  import config from './config.js';
9
10
 
@@ -114,6 +115,18 @@ async function plugin(fastify, opt) {
114
115
  });
115
116
  }
116
117
 
118
+ config.proxy?.forEach?.(el => {
119
+ fastify.register(proxy, {
120
+ upstream: el.target,
121
+ prefix: el.source,
122
+ http2: false,
123
+ preHandler: async (req) => {
124
+ req.headers.uid = req.session?.passport?.user?.uid;
125
+ Object.keys(el.headers || {})?.forEach(item => req.headers[item] = el.headers[item]);
126
+ },
127
+ });
128
+ });
129
+
117
130
  if (config.dblist) {
118
131
  dblistRoutes(fastify, opt);
119
132
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengis/fastify-table",
3
- "version": "1.4.57",
3
+ "version": "1.4.58",
4
4
  "type": "module",
5
5
  "description": "core-plugins",
6
6
  "keywords": [