Skip to content

Commit

Permalink
fixing protocol issue for player forwarding
Browse files Browse the repository at this point in the history
  • Loading branch information
adl-trey committed Aug 14, 2023
1 parent 57b2a18 commit fec0e09
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 16 deletions.
4 changes: 4 additions & 0 deletions cts/.env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
HOSTNAME=localhost

PLAYER_ROOT_PATH=/player
PLAYER_BASE_URL=http://player:3398/player
PLAYER_CONTENT_URL=http://localhost:3398/player/content
PLAYER_KEY=cts
PLAYER_SECRET=player-secret
Expand All @@ -9,3 +10,6 @@ PLAYER_TOKEN_SECRET=player-token-secret
LRS_ENDPOINT=http://host.docker.internal:8081/20.1.x/lrs/default/
LRS_USERNAME=dev-tools-xapi
LRS_PASSWORD=dev-tools-xapi-password

## Dev Only, set to 0 to allow self-signed certs
NODE_TLS_REJECT_UNAUTHORIZED=1
4 changes: 3 additions & 1 deletion cts/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,10 @@ services:
- DATABASE_USER=catapult
- DATABASE_USER_PASSWORD=quartz
- DATABASE_NAME=catapult_cts
- PLAYER_BASE_URL=http://player:3398${PLAYER_ROOT_PATH}
- PLAYER_BASE_URL
- PLAYER_KEY
- PLAYER_SECRET
- NODE_TLS_REJECT_UNAUTHORIZED
networks:
- public

Expand Down Expand Up @@ -103,6 +104,7 @@ services:

rdbms:
image: mysql:8.0.17
restart: always
volumes:
- catapult-cts-data:/var/lib/mysql
- ./init_db.sh:/docker-entrypoint-initdb.d/init_db.sh:ro
Expand Down
33 changes: 18 additions & 15 deletions player/service/plugins/routes/v1/courses.js
Original file line number Diff line number Diff line change
Expand Up @@ -714,10 +714,12 @@ module.exports = {
}

//Debug messages for troubleshooting host and path issuse - MB
console.log("req.url.protocol is ", req.url.protocol);
console.log("req.url.host is ", req.url.host);
console.log("rootPath is ", rootPath);
console.log("req.url.protocol is ", req.url.protocol);
// console.log("req.url.host is ", req.url.host);
// console.log("rootPath is ", rootPath);

let forwardingHeader = req.headers["x-forwarded-proto"];
let protocol = (forwardingHeader === "https") ? "https:" : req.url.protocol;

const lmsActivityId = courseAu.lms_id,
publisherActivityId = course.metadata.aus[auIndex].id,
Expand All @@ -728,7 +730,7 @@ module.exports = {
moveOn = req.payload.moveOn || courseAu.metadata.moveOn || "NotApplicable",
alternateEntitlementKey = req.payload.alternateEntitlementKey || courseAu.metadata.alternateEntitlementKey,

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

//Debug messages for troubleshooting host and path issuse - MB
console.log("Base url is ", baseUrl);
console.log("Which makes endpoint ", endpoint);
// //Debug messages for troubleshooting host and path issuse - MB
// console.log("Base url is ", baseUrl);
// console.log("Which makes endpoint ", endpoint);
// console.log("Forwarded Header: ", req.headers["x-forwarded-proto"]);

if (req.payload.contextTemplateAdditions) {
Hoek.merge(contextTemplate, req.payload.contextTemplateAdditions, { nullOverride: false });
Expand Down Expand Up @@ -781,10 +784,10 @@ module.exports = {
contextTemplate
};

//Debug messages for troubleshooting host and path issuse - MB
console.log("lmsLaunchDataStateParams.toString() is ", lmsLaunchDataStateParams.toString());
console.log("lmsLaunchDataStateParams is ", lmsLaunchDataStateParams);
console.log("lmsLaunchDataPayload is ", lmsLaunchDataPayload);
// //Debug messages for troubleshooting host and path issuse - MB
// console.log("lmsLaunchDataStateParams.toString() is ", lmsLaunchDataStateParams.toString());
// console.log("lmsLaunchDataStateParams is ", lmsLaunchDataStateParams);
// console.log("lmsLaunchDataPayload is ", lmsLaunchDataPayload);

if (courseAu.metadata.entitlementKey) {
lmsLaunchDataPayload.entitlementKey = {
Expand All @@ -811,10 +814,10 @@ module.exports = {
payload: lmsLaunchDataPayload
}
);
//Debug messages for troubleshooting host and path issuse - MB
console.log("lmsLaunchDataPayload is ", lmsLaunchDataPayload);
console.log("activities/state?${lmsLaunchDataStateParams.toString()} is ", `activities/state?${lmsLaunchDataStateParams.toString()}`);
console.log("lmsLaunchDataResponse is ", lmsLaunchDataResponse);
// //Debug messages for troubleshooting host and path issuse - MB
// console.log("lmsLaunchDataPayload is ", lmsLaunchDataPayload);
// console.log("activities/state?${lmsLaunchDataStateParams.toString()} is ", `activities/state?${lmsLaunchDataStateParams.toString()}`);
// console.log("lmsLaunchDataResponse is ", lmsLaunchDataResponse);

lmsLaunchDataResponseBody = await Wreck.read(lmsLaunchDataResponse, { json: true });

Expand Down

0 comments on commit fec0e09

Please sign in to comment.