Skip to content

Conversation

@arladmin
Copy link

Context

#1549 (comment)

Proposed solution

Always use the APP_HOME_URL env variable (if set) to create the Auth Redirect url.

Related issues

#1549 (comment)

Has this been tested?

  • 👍 yes, I added tests to the test suite
  • 💭 no, because this PR is a draft and still needs work
  • 🙅 no, because this is not relevant here
  • 🙋 no, because I need help

Screenshots / Screencasts

Always use the APP_HOME_URL env variable (if set) to create the Auth Redirect url.
@georgegevoian georgegevoian self-requested a review May 22, 2025 14:51
@berhalak berhalak self-assigned this May 22, 2025
@berhalak berhalak self-requested a review May 23, 2025 09:06
const homeUrl = process.env.APP_HOME_URL;
// if homeUrl is localhost - (in dev environment) - use the development url
if (homeUrl && new URL(homeUrl).hostname === "localhost") {
if (homeUrl) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about adding a dedicated variable for this redirect? Something like:

Suggested change
if (homeUrl) {
if (process.env.GRIST_GOOGLE_IMPORT_REDIRECT_URL) {
return process.env.GRIST_GOOGLE_IMPORT_REDIRECT_URL;
}
if (homeUrl && new URL(homeUrl).hostname === "localhost") {

and leaving the code as it is? It will be much simpler to manage this integration this way, rather then constructing those URL by hand.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@berhalak Do correct me if i'm wrong, but:
in the case of GRIST_GOOGLE_IMPORT_REDIRECT_URL, user will need to know what to fill in, whereas,
in the case of just the APP_HOME_URL, no intervention is really required.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but:

  • user already needs to know what to put in APP_HOME_URL,
  • this code that checks localhost is needed, I think, for some tests to work properly,
  • this change will probably break some existing installation that relies on this format

With new env variable, this change will be backward compatible, and would require minimal tests change.

Copy link
Author

@arladmin arladmin May 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With new env variable, this change will be backward compatible, and would require minimal tests change.

No denying that.

But, in that case, the user will also need to take care of the authHandlerPath in

  if (homeUrl && new URL(homeUrl).hostname === "localhost") {
    return `${homeUrl}${authHandlerPath}`;
  }

when formulating the GRIST_GOOGLE_IMPORT_REDIRECT_URL, and that will need to be properly documented as well.

My suggestion was to get only the instance URL (which happens to be equal to the APP_HOME_URL value) from the user, and append the authHandlerPath to that subsequently.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we would need to put the format of that URL in the property description in the README.md.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rest of the code in getFullAuthEndpointUrl() does look very specific to the Grist Labs SaaS in its handling of domains. Perhaps, after the local dev case, there could be another case that kicks in for simple (and common) single-domain instances of Grist?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants