Open MPH-DZP opened 1 year ago
Great point. We should use the fusionAuthURL
variable.
More suggestions:
npm install cross-env
so that package.json
can have scripts like these:
"scripts": {
"dev": "cross-env NODE_ENV=development nodemon index",
"start": "cross-env NODE_ENV=production node index"
}
sUrlThatAuthenticationServerShouldRedirectToAfterProcessingUserLoginResponse = sProtocolDomainAndPortOfThisApp + sQueryPath_decodeOauthSuccess
so that at the index.js location highlighted in OP, provide the value as sUrlThatAuthenticationServerShouldRedirectToAfterProcessingUserLoginResponse
. Similarly, when defining the route to handle the authorization or registration result request from the FA instance, use oRouter.get(sQueryPath_decodeOauthSuccess, ...
to emphasize that this route handler is the intended recipient of the redirect specified in the /authorize or /register request.layout.ejs
, provide them in the locals used to render 'home':
oResponse1.render(
'home',
{
user: oRequest1.session.user,
urlToSignup: `${sBaseUrl_FusionAuth}/oauth2/register?client_id=${sClientId_FusionAuth}&response_type=code&redirect_uri=${sUrlThatAuthenticationServerShouldRedirectToAfterProcessingUserLoginResponse}&scope=offline_access&state=${dStateValue}&code_challenge=${sChallenge}&code_challenge_method=S256`,
urlToLogin: `${sBaseUrl_FusionAuth}/oauth2/authorize?client_id=${sClientId_FusionAuth}&response_type=code&redirect_uri=${sUrlThatAuthenticationServerShouldRedirectToAfterProcessingUserLoginResponse}&scope=offline_access&state=${dStateValue}&code_challenge=${sChallenge}&code_challenge_method=S256`,
urlToMyProfile: `${sBaseUrl_FusionAuth}/account/?client_id=${sClientId_FusionAuth}`
}
);
so that layout.ejs
can reference them like this:
<a class="ui item" href="<%= locals.urlToLogin %>">
Authorized redirect URLs
in one's FA admin webconsole (for FA Cloud instances: by going to https://YOUR_FA_HOST_GOES_HERE/admin/application/ and clicking the edit button for one's app).required
in one's Application settings?
It seems to be a bug (at least for non-localhost use) that the following lines hard-code localhost:
https://github.com/FusionAuth/fusionauth-example-5-minute-guide/blob/22652f49d2c4d2bb62a74947124bc72106c35937/routes/index.js#L55
https://github.com/FusionAuth/fusionauth-example-5-minute-guide/blob/22652f49d2c4d2bb62a74947124bc72106c35937/views/index.pug#L12