Skip to content

Commit

Permalink
Issue #IQ-801 merge: Fix local setup for development
Browse files Browse the repository at this point in the history
Issue #IQ-801 fix: Fix local setup for development
  • Loading branch information
AmiableAnil authored May 28, 2024
2 parents 35e6133 + fe89067 commit bd08fdd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
9 changes: 9 additions & 0 deletions .env_example
Original file line number Diff line number Diff line change
@@ -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"
14 changes: 7 additions & 7 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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= ""
Expand All @@ -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;
}
};
Expand All @@ -39,22 +39,22 @@ 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);
return urlHelper.parse(req.url).path;
},
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',
Expand Down

0 comments on commit bd08fdd

Please sign in to comment.