public directory is not deployed on AWS Amplify

2.3k Views Asked by At

I am working on a project built by React/IONIC. Now I'm trying to add social sign in to the application, and to do so I need to put a file in the following directory: /.well-known/apple-app-site-association

But the issue is, whenever I try to deploy the app on Amplify (it's connected to github repo), it doesn't deploy /public folder.

My Amplify.yml file is as follows:

version: 1.2.9 env: variables: REACT_APP_API_ENDPOINT: https://******.execute-api.ca-central-1.amazonaws.com/staging frontend: phases: preBuild: commands: ['npm ci'] build: commands: ['npm run build'] artifacts: baseDirectory: build files: - '**/*' cache: paths: - 'node_modules/**/*'

I would really appreciate your help here.

3

There are 3 best solutions below

0
debugguru On

contents of public folder are deployed on root folder. So you /.well-known/apple-app-site-association will be available from https://<yourdomian.com>/.well-known/apple-app-site-association

You will have to add custom Rewrites and Redirect in AWS Amplify in AWS Console as the default Rewrite will redirect all request to Index.html for React App to handle

0
Sébastien NOBOUR On

So far I just deployed a React app on Amplify. And I do not ask in amplify.yml the deployment of the public/ folder. Rather I create a build of my project with a yarn build, which embeds the content of the public folder inside the new build/ folder. So I hope Ionic does not ask to deploy the public folder on top of build/ folder.

I figured out as well that I needed to configure the URL routes inside rewrite and redirect menu of Amplify whenever my react app makes GET requests like my-domain.com/privacy.pdf.

As long as I did not specify the ".pdf" in the previously existing...

</^[^.]+$|\.(?!(css|gif|ico|jpg|js|png|txt|svg|woff|ttf|map|json)$)([^.]+$)/>   /index.html 200 (Rewrite)`

...rule, the routing was not able to fetch the privacy.pdf file.

I would suggest to look at the file extension of your logo too if the file extension of the sign you try to load is not included in the rewrite rule.

0
testing_22 On

TL;DR

Remove all of your redirects, so it will host the public folder and its contents. enter image description here

There's no need to redeploy the server. The changes are made on the fly.