Skip to content

Commit

Permalink
adding optional override for player's launch url base
Browse files Browse the repository at this point in the history
  • Loading branch information
adl-trey committed May 22, 2024
1 parent b650497 commit 7fffbb5
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
3 changes: 2 additions & 1 deletion cts/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ HOSTNAME=localhost

PLAYER_ROOT_PATH=/player
PLAYER_BASE_URL=http://player:3398/player
PLAYER_CONTENT_URL=http://localhost:3398/player/content
PLAYER_CONTENT_URL=http://localhost/player/content
PLAYER_LAUNCH_URL_BASE=http://localhost/player
PLAYER_KEY=cts
PLAYER_SECRET=player-secret
PLAYER_TOKEN_SECRET=player-token-secret
Expand Down
1 change: 1 addition & 0 deletions player/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ LRS_XAPI_VERSION=1.0.3

## Default is empty, add if necessary for nginx config
PLAYER_API_ROOT=
PLAYER_LAUNCH_URL_BASE=
8 changes: 3 additions & 5 deletions player/service/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions player/service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@
"libxmljs": "^0.19.8",
"mysql": "^2.18.1",
"node-stream-zip": "^1.13.6",
"uuid": "^9.0.1",
"wait-port": "^0.2.9"
},
"devDependencies": {
"chai": "^4",
"dotenv": "^16.4.5",
"mocha": "^10.4.0",
"uuid": "^9.0.1"
"mocha": "^10.4.0"
}
}
7 changes: 4 additions & 3 deletions player/service/plugins/routes/v1/courses.js
Original file line number Diff line number Diff line change
Expand Up @@ -730,8 +730,6 @@ module.exports = {
moveOn = req.payload.moveOn || courseAu.metadata.moveOn || "NotApplicable",
alternateEntitlementKey = req.payload.alternateEntitlementKey || courseAu.metadata.alternateEntitlementKey,

baseUrl = `${protocol}//${req.url.host}${rootPath}`,
endpoint = `${baseUrl}/lrs`,
sessionId = uuidv4(),
contextTemplate = {
contextActivities: {
Expand All @@ -746,6 +744,9 @@ module.exports = {
}
};

let launchURLBase = (process.env.PLAYER_LAUNCH_URL_BASE || `${protocol}//${req.url.host}${rootPath}`);
let endpoint = `${launchURLBase}/lrs`;

// //Debug messages for troubleshooting host and path issuse - MB
// console.log("Base url is ", baseUrl);
// console.log("Which makes endpoint ", endpoint);
Expand Down Expand Up @@ -923,7 +924,7 @@ module.exports = {
const launchUrlParams = new URLSearchParams(
{
endpoint,
fetch: `${baseUrl}/fetch-url/${session.id}`,
fetch: `${launchURLBase}/fetch-url/${session.id}`,
actor: JSON.stringify(actor),
activityId: lmsActivityId,
registration: reg.code
Expand Down

0 comments on commit 7fffbb5

Please sign in to comment.