Skip to content

Commit

Permalink
Merge pull request #554 from bcgov/fix/eccc-swrs-api-node-fetch
Browse files Browse the repository at this point in the history
Fix: node fetch request pipe
  • Loading branch information
pbastia authored May 31, 2024
2 parents 7551fac + 8b72300 commit a0af102
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion ggircs-app/app/server/routers/api/eccc.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
require("isomorphic-fetch");
const express = require("express");
const dotenv = require("dotenv");
const { WritableStream } = require("node:stream/web");
const { isAuthenticated } = require("@bcgov-cas/sso-express/dist/helpers");
const { getUserGroups } = require("../../helpers/userGroupAuthentication");
const { getUserGroupLandingRoute } = require("../../../lib/user-groups");

dotenv.config();

const ecccApiRouter = express.Router();

const { ECCC_FILE_BROWSER_HOST, ECCC_FILE_BROWSER_PORT, HOST, PORT } =
process.env;

Expand Down Expand Up @@ -83,7 +88,16 @@ ecccApiRouter.get(
if (contentDispositionHeader)
res.setHeader("Content-Disposition", contentDispositionHeader);

ecccApiRes.body.pipe(res);
ecccApiRes.body.pipeTo(
new WritableStream({
write: (chunk) => {
res.write(chunk);
},
close: () => {
res.end();
},
})
);
}
);

Expand Down

0 comments on commit a0af102

Please sign in to comment.