-
Notifications
You must be signed in to change notification settings - Fork 387
Add a new utility for constructing the host URL for the app. #419
Conversation
@paulomarg @vividviolet this is now ready for review. I'm going to test the code manually in the app template. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good to me. I wonder if the util should be called getEmbeddedAppUrl
or something? It's not useful for non-embedded apps as the url would not work.
src/utils/get-host-app-url.ts
Outdated
); | ||
} | ||
|
||
if (!request.url) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this actually possible?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought url was always a string according to this https://nodejs.org/api/http.html#messageurl
6da23f4
to
774e7a8
Compare
@vividviolet Agreed. |
774e7a8
to
02bd65c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nits aside, I think this works!
05ea6a2
to
ab55983
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me
1. Correct typo 2. Change utility name "getHostAppUrl" to "getEmbeddedAppUrl", which is much nicer. 3. Add / to the host in our test. This matches the format of the host that Shopify provides 4. Flesh out the docs a little more. 5. Use new URL, rather than url.parse. url.parse is deprecated.
ab55983
to
4cf0bef
Compare
WHY are these changes introduced?
For performance soon we will be recommending that apps favor server redirects within the OAuth process. This will replace client side redirects using AppBridge. We want to control that code that constructs the URL for the app. That way it's easier for developers, and if that URL changes we can update the logic with a version bump.
WHAT is this pull request doing?
Add a new utility called
getHostAppUrl
. This utility constructs the host URL for an app.This utility will be used to get the URL to redirect to when the store does not have a token for the app.
Type of change
Checklist