mdenet / educationplatform

Eclipse Public License 2.0
2 stars 3 forks source link

Add support for customising the URL to the token server #125

Closed agarciadom closed 8 months ago

agarciadom commented 8 months ago

I have started to look into deploying a public instance of the platform. From what I can see, it seems like the token server URL was hardcoded into the JavaScript code:

const TOKEN_HANDLER_URL = "http://127.0.0.1:10000";

This pull request allows for customising the URL of the token handler, by using a Webpack DefinePlugin. The line can be changed to:

const TOKEN_HANDLER_URL = TOKEN_SERVER_URL || "http://127.0.0.1:10000";

The TOKEN_SERVER_URL value will be replaced on the fly by Webpack using the DefinePlugin. This would allow us to tweak the URL by using the appropriate value when calling npm, like this:

npm run build -- --env tokenServerUrl=http://foo:1234

I had to separate the copyfiles invocation into its own npm run package script, as otherwise I wasn't able to pass Webpack environment variables to the build.