Skip to content

On AWS Amplify my customHttp.yml file is not being used

0

I have had a customHttp.yml file to store custom headers including content security policy for a long time now. It has worked for a while. However, recently it stopped updating on my app. This seems to have tied in with the Amplify redesign although that may just be a coincidence. I have two branches; staging and master. Master is used for production and staging for, well, staging. We have not updated production for a while and I am concerned to do so because I am concerned that we may lose our custom headers.

I am not sure how the customHttp.yml ties in with branches because this appears to be independent of branches and works across all of them. I updated the custom headers in the UI and redeployed my staging site but this has not made a difference.

Thanks in advance

asked 2 years ago675 views

2 Answers
1

It seems you're experiencing an issue with your customHttp.yml file not being applied in AWS Amplify. This is a concerning situation, especially given the importance of custom headers like content security policy.

First, it's important to note that the customHttp.yml file should indeed work across all branches, as you've correctly observed. It's not branch-specific, which is why you're seeing the issue on both your staging and master branches.

The fact that updating the custom headers in the UI and redeploying didn't resolve the issue suggests that there might be a problem with how Amplify is processing your configuration file. Here are a few steps you can try to troubleshoot and potentially resolve the issue:

  1. Verify the location of your customHttp.yml file. It should be in the root of your project directory.

  2. Double-check the syntax and formatting of your customHttp.yml file. Even small errors can cause the file to be ignored.

  3. Try renaming the file to amplify.yml and include your custom headers under a 'customHeaders' section. This is an alternative way to specify custom headers that might work if the customHttp.yml file is being overlooked for some reason.

  4. Attempt to invalidate the cache for your Amplify app. You can do this through the Amplify Console or using the Amplify CLI command 'amplify cache invalidate'.

  5. If possible, try creating a new branch from your master, make a small change, and deploy it to see if the custom headers are applied correctly on a fresh deployment.

  6. Check your build logs for any warnings or errors related to custom headers or the customHttp.yml file.

If none of these steps resolve the issue, it would be advisable to contact AWS support, as there might be an underlying problem with how Amplify is handling your configuration.

Regarding your concern about updating production, it would be wise to thoroughly test any changes on your staging environment first. If you're still unable to get the custom headers working on staging, it might be best to hold off on updating production until the issue is resolved to avoid potentially losing your custom headers in the production environment.

Remember, any changes to your security headers, especially the Content Security Policy, should be carefully tested to ensure they don't break any functionality of your site while still providing the necessary security.

Sources
Issue with AWS Amplify Deployment on Custom Domain | AWS re:Post
AWS Amplify FAQs | Front-End Web & Mobile | Amazon Web Services

answered 2 years ago

EXPERT

reviewed 2 years ago

EXPERT

reviewed 2 years ago

0

So I think that I have solved this based on the AI answer. I was using the yaml multi line format with the folded symbol. Apparently Amplify does not like this format and rejected it. When I put it back to all on one line it worked again.

answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.