From 7497832b0abcb1a534eabf19945b6389671b1541 Mon Sep 17 00:00:00 2001 From: Rajnish Dargan Date: Mon, 27 May 2024 13:38:07 +0530 Subject: [PATCH 1/2] Issue #IQ-801 fix: Fix local setup for development --- .env_example | 9 +++++++++ server.js | 14 +++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) create mode 100644 .env_example diff --git a/.env_example b/.env_example new file mode 100644 index 000000000..abafd6a8d --- /dev/null +++ b/.env_example @@ -0,0 +1,9 @@ +# For running the server, rename this file to .env + +# Update the following values with your actual information: + +# Base URL for API requests in below format - make sure not to add any additional slash in the end. +BASE_URL="dev.sunbirded.org" + +# Your API token for authentication +AUTH_API_TOKEN="XXYY" diff --git a/server.js b/server.js index 3cb2568cd..e606ce51c 100644 --- a/server.js +++ b/server.js @@ -7,7 +7,7 @@ const latexService = require('./latexService.js') const dotenv = require('dotenv'); dotenv.config(); -const BASE_URL = process.env.BASE_URL || "dev.inquiry.sunbird.org"; +const BASE_URL = process.env.BASE_URL || "dev.sunbirded.org"; const API_AUTH_TOKEN = process.env.AUTH_API_TOKEN; const USER_TOKEN = process.env.USER_API_TOKEN; const PORTAL_COOKIES= "" @@ -22,7 +22,7 @@ app.use(express.static(__dirname + '/web-component-examples/vanilla-js')); const decoratePublicRequestHeaders = function () { return function (proxyReqOpts, srcReq) { proxyReqOpts.headers['authorization'] = `Bearer ${API_AUTH_TOKEN}`; - proxyReqOpts.headers['x-authenticated-user-token'] = USER_TOKEN; + // proxyReqOpts.headers['x-authenticated-user-token'] = USER_TOKEN; return proxyReqOpts; } }; @@ -39,10 +39,9 @@ app.post(["/action/asset/v1/upload/*"], proxy(BASE_URL, { }) ); -app.all(['/api/framework/v1/read/*', +app.get(['/api/framework/v1/read/*', '/learner/framework/v1/read/*', - '/api/channel/v1/read/*', - '/api/question/v2/list'], proxy(BASE_URL, { + '/api/channel/v1/read/*'], proxy(BASE_URL, { https: true, proxyReqPathResolver: function(req) { console.log('proxyReqPathResolver ', urlHelper.parse(req.url).path); @@ -50,11 +49,12 @@ app.all(['/api/framework/v1/read/*', }, proxyReqOptDecorator: decoratePublicRequestHeaders() })); + + app.use(['/action/questionset/v2/*', '/action/question/v2/*', - '/action/collection/v1/*', '/action/object/category/definition/v1/*', - '/action/collection/v1/*' + '/api/question/v2/*' ], proxy(BASE_URL, { https: true, limit: '30mb', From fe89067cae99495fcf6e20b591e0099258ae7657 Mon Sep 17 00:00:00 2001 From: Rajnish Dargan Date: Mon, 27 May 2024 13:41:15 +0530 Subject: [PATCH 2/2] Re Run test case