Skip to content
Snippets Groups Projects
Commit 3b5d034d authored by Xiao Gui's avatar Xiao Gui
Browse files

use redirect for cached dataset

parent a57bac08
No related branches found
No related tags found
No related merge requests found
const CACHED_DATASET_URL = process.env.CACHED_DATASET_URL
const got = require('got')
exports.handler = (ev, ctx, cb) => {
const {
path,
......@@ -18,14 +17,12 @@ exports.handler = (ev, ctx, cb) => {
const [ _, templateName, parcellationName ] = re
if (CACHED_DATASET_URL) {
got(CACHED_DATASET_URL)
.then(text => cb(null, {
status: 200,
body: text,
headers: {
'content-type': 'application/json'
}
}))
cb(null, {
status: 302,
headers: {
'Location': CACHED_DATASET_URL
}
})
} else {
return cb(null, {
status: 200,
......
{
"name": "datasets",
"version": "1.0.0",
"description": "",
"main": "datasets.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "apache-2.0",
"dependencies": {
"got": "^11.1.4"
}
}
......@@ -2,6 +2,6 @@
[build]
publish="dist/aot/"
command="cp deploy/util/* functions/nehubaConfig/ && cp -R src/res/ext functions/templates/json && cp -R src/res/ext functions/nehubaConfig/json && npm run build-aot && cd functions/datasets && npm i"
command="cp deploy/util/* functions/nehubaConfig/ && cp -R src/res/ext functions/templates/json && cp -R src/res/ext functions/nehubaConfig/json && npm run build-aot"
functions="functions"
environment={ BACKEND_URL=".netlify/functions/" }
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment