amplify-hosting icon indicating copy to clipboard operation
amplify-hosting copied to clipboard

Feature request: Use custom domain in PR comment for preview link

Open d-luk opened this issue 3 years ago • 18 comments

Is your feature request related to a problem? Please describe. When a PR is created, the AWS Amplify GitHub bot comments the preview URL, as added in #264. This is great, except that we are using a custom domain.

image

So the comment mentions https://pr-{PR}.{APP_ID}.amplifyapp.com, while it should be https://pr-{PR}.example.com.

This is important for us because our app does not work on the amplifyapp.com domain due to CORS restrictions, so we must use our custom domain.

Describe the solution you'd like Please allow configuring the PR bot to use a custom domain.

d-luk avatar Oct 05 '21 11:10 d-luk

Hi Duncan! 👋🏽 Thanks for raising this feature request. Currently, the Web Previews feature is only available for Amplify apps connected to custom domains managed by Amazon Route 53. We will review this feature request further with the team. 🙂

ghost avatar Oct 05 '21 21:10 ghost

Hi @hloriana in our app we use Route 53 for costom domains, but this comment shows same amplifyapp.com domain as on @d-luk screenshot

svekl avatar Oct 06 '21 17:10 svekl

Same issue here, everything works fine with our custom domain, except Amplify now adds bogus comment in all our PRs revealing the amplifyapp.com subdomains that were supposed to be hidden, and are not functioning in our use cases.

TL;DR this creates a huge mess

callms avatar Oct 07 '21 15:10 callms

The same here!

We create two environments with amplify and we can't identify who is on PR comment.

image

giioohbernini avatar Oct 08 '21 17:10 giioohbernini

I'm experiencing the same issue. I have a custom domain set up in Route 53 and subdomain auto-detection is enabled and working for PRs. However, the Github App still uses the amplifyapp.com domain in the PR comment.

joebanks10 avatar Oct 25 '21 14:10 joebanks10

Any news maybe this issue is being investigated?

I'd love not to write a robot that deletes the Amplify comments.

callms avatar Oct 26 '21 16:10 callms

Any other news or updates? Or does anyone have a workaround that drags in the correct link each time?

mbuffoQSR avatar Mar 30 '22 20:03 mbuffoQSR

Hi Duncan! 👋🏽 Thanks for raising this feature request. Currently, the Web Previews feature is only available for Amplify apps connected to custom domains managed by Amazon Route 53. We will review this feature request further with the team. 🙂

Hi @hloriana , have you discussed this feature with the team? We also would love to use such a feature to avoid CORS restrictions.

andreadeluisi-ryte avatar Nov 08 '22 10:11 andreadeluisi-ryte

Same issue here. We were able to create previews under the custom domain (and the Preview URL in the AWS Console actually shows the right domain), but the comment is still sent with the amplify domain. This would be quite important for us to resolve, as it creates unnecessary friction and confusion with the dev team.

santiagoaguiar avatar Dec 09 '22 14:12 santiagoaguiar

@santiagoaguiar how do you guys set it up to use custom domain for previews? I connected our domain successfully, but pr previews are still created on *.amplifyapp.com which yeah due to CORS issues are not what we want at all.

sorokinvj avatar Jan 02 '23 11:01 sorokinvj

@sorokinvj if you have a domain registered in route 53 you can connect it in the domain management page from the amplify page on the AWS site. Then on gh I just wrote a bot that would post the correct link based on the branch name since our branches + prs are named predictably

mbuffoQSR avatar Jan 02 '23 17:01 mbuffoQSR

@sorokinvj we had to enable branch deployments for all the PRs (this was unexpected, I would have expected just enabling previews would be enough).

That being said, we dropped this as we run into other issues:

  1. (this issue) The comment was confusing for users, we attempted to hack it through GitHub actions to edit the message but amplify keep posting new ones. We opted to minimize Amplify comment and add ours which did the trick but was quite ugly.
  2. Most of our PRs are created from branches with / in the name. For some reason, custom domains where not created for those PRs, which made the feature unusable for us. We did most of the setup on a branch without a / on it so we caught this a bit later in the process...

Honestly, this was something we expected to be simple and ended up spending more time that we wanted on it. We might do another pass at this later, or just move to something else.

santiagoaguiar avatar Jan 02 '23 20:01 santiagoaguiar

Any update on this issue? We are experiencing the same problem

dranes avatar Apr 28 '23 01:04 dranes

Any updates on this issues? I was able to connect the PR Previews to my custom domain but in Github the bot added a message that is displaying the amplify domain.

image

alerojasv147 avatar Jun 30 '23 21:06 alerojasv147

+1 I would also prefer to have the domain name in the bot comment either configurable or default to using a custom domain if there is a custom domain present.

nikki-quant avatar Oct 16 '23 13:10 nikki-quant

+1 as well, we have a use case where domains are allow listed for CORS headers and the comments are basically useless and confusing

OrenMe avatar Oct 25 '23 12:10 OrenMe

We ended up using a GitHub action to try to fix the issue.

on:
  issue_comment:
    types: [created]
jobs:
  pr_commented:
    name: PR comment
    if: ${{ github.event.issue.pull_request &&  contains(github.event.comment.user.login, 'aws-amplify-us-east-1[bot]') }}
    runs-on: ubuntu-latest
    steps:
      - run: |
          echo trying to edit comment on PR $NUMBER $USER_ID $COMMENT_ID
        env:
          USER_ID: ${{ github.event.comment.user.login }}
          COMMENT_ID: ${{ github.event.comment.id }}
          NUMBER: ${{ github.event.issue.number }}
      - name: Update comment
        uses: peter-evans/create-or-update-comment@v3
        with:
          edit-mode: replace
          comment-id: ${{github.event.comment.id}}
          body: |
            This pull request is automatically being deployed by Amplify Hosting ([learn more](https://aws.amazon.com/amplify/hosting/)).<br/><br/>Access this pull request here: https://pr-${{github.event.issue.number}}.example.com

dranes avatar Oct 31 '23 12:10 dranes

We don't seem to be able to configure custom domain for PR Previews yet, anyone has a guide for it? We followed this guide and no luck.

Also, perhaps removing Amplify App from GitHub and connecting it again may do the trick for those having the old non-custom domain posted in PRs.

leog avatar Dec 15 '23 16:12 leog