@data-fair/dev-server 1.7.2 → 1.7.3
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.
- package/package.json +1 -1
- package/server/app.js +13 -1
package/package.json
CHANGED
package/server/app.js
CHANGED
|
@@ -50,8 +50,8 @@ dataFairOutputWS.on('open', () => dataFairOutputWS.send('connect to external web
|
|
|
50
50
|
dataFairOutputWS.on('message', (data) => { if (dataFairWS) dataFairWS.send(data.toString()) })
|
|
51
51
|
dataFairOutputWS.on('error', (err) => console.error('failed to connect to external websocket server', dfWsUrl, err))
|
|
52
52
|
|
|
53
|
-
app.use(bodyParser.json())
|
|
54
53
|
app.use(cors())
|
|
54
|
+
app.use(bodyParser.json())
|
|
55
55
|
|
|
56
56
|
// very basic CRUD of config
|
|
57
57
|
app.get('/config', (req, res, next) => {
|
|
@@ -183,8 +183,11 @@ app.use('/data-fair', createProxyMiddleware({
|
|
|
183
183
|
onProxyReq (proxyReq, req, res) {
|
|
184
184
|
// no gzip so that we can process the content
|
|
185
185
|
proxyReq.setHeader('accept-encoding', 'identity')
|
|
186
|
+
|
|
187
|
+
// authentication through api key only
|
|
186
188
|
proxyReq.setHeader('cookie', '')
|
|
187
189
|
if (config.dataFair.apiKey) proxyReq.setHeader('x-apiKey', config.dataFair.apiKey)
|
|
190
|
+
|
|
188
191
|
// body was already parsed by body-parser and no longer available as a stream
|
|
189
192
|
fixRequestBody(proxyReq, req, res)
|
|
190
193
|
},
|
|
@@ -207,6 +210,15 @@ app.use('/data-fair', createProxyMiddleware({
|
|
|
207
210
|
}
|
|
208
211
|
}))
|
|
209
212
|
|
|
213
|
+
// also re-expose the simple-directory instance matching data-fair
|
|
214
|
+
if (dfUrl.pathname === '/data-fair') {
|
|
215
|
+
app.use('/simple-directory', createProxyMiddleware({
|
|
216
|
+
target: dfUrl.origin,
|
|
217
|
+
secure: false,
|
|
218
|
+
changeOrigin: true
|
|
219
|
+
}))
|
|
220
|
+
}
|
|
221
|
+
|
|
210
222
|
// run the dev-src command from current project
|
|
211
223
|
let spawnedDevSrc
|
|
212
224
|
|