aws-amplify / amplify-hosting

AWS Amplify Hosting provides a Git-based workflow for deploying and hosting fullstack serverless web applications.
https://aws.amazon.com/amplify/hosting/
Apache License 2.0
460 stars 116 forks source link

AWS amplify redirect issue with apple-app-site #1983

Closed josea2pp closed 2 years ago

josea2pp commented 3 years ago

Before opening, please confirm:

App Id

No response

Region

us-east-1

Amplify Console feature

No response

Describe the bug

I'm using aws amplify to host my front end but im getting a issue putting the universal link for ios, i put the apple-app-site-association in my root folder and create a rule in redirect part to point to that file but without extension it just get 404 but if i put and ext .json it works, the problem is that apple required that the file does't have extensions.

this is muy current config and my file is located in /root/apple-app-site-association { "source": "/apple-app-site-association", "target": "/apple-app-site-association", "status": "200", "condition": null } ]

Expected behavior

That aws allow me put files without extension

Reproduction steps

upload a file without extension redirect with a rule to that file see if it work

Build Settings

No response

Additional information

No response

github-actions[bot] commented 3 years ago

Hi :wave:, thanks for opening! While we look into this...

If this issue is related to custom domains, be sure to check the custom domains troubleshooting guide to see if that helps. Also, there is a more general troubleshooting FAQ that may be helpful for other questions.

Lastly, please make sure you've specified the App ID and Region in the issue!

victorccccc commented 3 years ago

Hi, Can you add this custom rule:

[
    {
        "source": "/.well-known/apple-app-site-association",
        "target": "/apple-app-site-association",
        "status": "200",
        "condition": null
    }
]
josea2pp commented 3 years ago

Victor, thanks for the reply,

But in that case do i have to create a sub directory on mi root? like root/.well-known/apple-app.site-association?

victorccccc commented 3 years ago

Victor, thanks for the reply,

But in that case do i have to create a sub directory on mi root? like root/.well-known/apple-app.site-association?

No, you can keep apple-app-site-association in root folder.

josea2pp commented 3 years ago

not, it seems that doesn't work it bring me the 404

these are my rules

[ { "source": "/.well-known/apple-app-site-association", "target": "/apple-app-site-association", "status": "200", "condition": null }, { "source": "/<*>", "target": "/index.html", "status": "404-200", "condition": null }, { "source": "</^[^.]+$|\.(?!(css|gif|ico|jpg|js|png|txt|svg|woff|ttf|map|json)$)([^.]+$)/>", "target": "/index.html", "status": "200", "condition": null } ]

victorccccc commented 3 years ago

not, it seems that doesn't work it bring me the 404

these are my rules

[ { "source": "/.well-known/apple-app-site-association", "target": "/apple-app-site-association", "status": "200", "condition": null }, { "source": "/<*>", "target": "/index.html", "status": "404-200", "condition": null }, { "source": "</^[^.]+$|.(?!(css|gif|ico|jpg|js|png|txt|svg|woff|ttf|map|json)$)([^.]+$)/>", "target": "/index.html", "status": "200", "condition": null } ]

Sorry for the confusion, is the root folder a folder in your Repo? Could you put apple-app-site-association in root of your repo as target is /apple-app-site-association ?

Ref: https://github.com/aws-amplify/amplify-console/issues/1209

r0nanoc commented 3 years ago

Hi, I have tried this approach but get error. My rule is configured similar to previous comment... [ { "source": "/.well-known/apple-app-site-association", "target": "/apple-app-site-association", "status": "200", "condition": null } ]

However when I go to 'Add a new domain' on stripe settings --> payment methods, I get error:

We were unable to verify that you control the domain my-domain.com. When we tried to request https://my-domain.com/.well-known/apple-developer-merchantid-domain-association, it redirected to /.well-known/apple-developer-merchantid-domain-association/. The verification file must be served as a 200 at https://my-domain.com/.well-known/apple-developer-merchantid-domain-association to register my-domain.com. Did you mean to register /.well-known/apple-developer-merchantid-domain-association/?

If I access directly in browser, it gives 403 error: ** AccessDenied

Access Denied 0DF9RH2HHD0FADRN WgIpBLcTGkEZiKh+1/hjkgidisajeLJvn97Wfnm1YIJG+RCFxtDY=

**

Appreciate any help here.

jameyel commented 3 years ago

@r0nanoc getting the same error. hoping someone can help with this.

tamagokun commented 3 years ago

Solution is that the file itself NEEDS a file extension, and the redirect does not:

[
    {
        "source": "/.well-known/apple-app-site-association",
        "target": "/.well-known/apple-app-site-association.json",
        "status": "200",
        "condition": null
    }
]

Then amplify will be able to find it correctly.

chris commented 3 years ago

Note, @tamagokun 's answer worked for me, but just an FYI that if I put this URL in my browser, it results in the typical Amplify/CloudFront AccessDenied XML error. But, if I curl the URL, it delivers me the file just fine.

calavera commented 2 years ago

Thanks for providing the solution to this issue @tamagokun ! I'm going to close this issue, and I will open a new one in the docs repository so we can add this to our docs.

github-actions[bot] commented 2 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.