-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(amplify-alpha): customResponseHeaders
does not support monorepo structures
#31758
Comments
So it seems like CDK is creating this custom headers yaml, which is fine for regular applications: customHeaders:
- pattern: "**"
headers:
- key: Test
value: test However, for monorepos, this custom headers yaml is required: applications:
- appRoot: frontend
customHeaders:
- pattern: "**"
headers:
- key: Test
value: test When I change the yaml in the console, this passes the Amplify deployment. So should we add an optional customResponseHeaders: [
{
appRoot: 'frontend',
pattern: '**',
headers: {
'Test': 'test',
},
},
], I'm happy to try and submit a PR if so. |
@ashishdhingra My apologies, I do I've tested this further and my first reply comment sums up what is actually happening. Currently the amplify package does not support adding custom response headers for monorepo structures due to the differences in yaml I outlined above. I've actually made a few changes to the amplify package locally and gotten it working for monorepos, I should be able to get a PR submitted tomorrow if you're willing to take a look? |
Submitted as a draft now: #31771 |
@georeeve Thanks for your response. Per CDK Amplify API doc, it does support Adding custom response headers. Please advise if you have tried using the The PR would be reviewed by CDK team on incoming priority. Thanks, |
@ashishdhingra I'm a bit confused, I was specifying it in the For clarity, Amplify supports two main repository structures. A single repository structure (non-monorepo) and a monorepo structure (see https://docs.amplify.aws/react/deploy-and-host/fullstack-branching/monorepos/). CDK does support setting custom response headers through the My PR additionally adds support for monorepo structures, by converting it to the second example code block above. Given that this limitation is not explicitly stated in the docs, I'm guessing it's an oversight of the initial implementation. @ayush987goyal are you able to provide any more info? Looking through previous PRs, you added the property in #17102. As an aside, I think you can specify it in the buildSpec instead, but it seems like that's deprecated: https://docs.aws.amazon.com/amplify/latest/userguide/migrate-custom-headers.html |
customResponseHeaders
does not support monorepo structures
@georeeve Thanks for clarification and apologies for confusion. |
Describe the bug
Firstly, I can't tell if this is a CDK or Amplify issue. aws-amplify/amplify-hosting#1995 seems related, but someone in that issue was using
customHttp.yml
which we can't do on CDK.I've tried to condense this into a simple example app below. It works without the
customResponseHeaders
property. However, when I addcustomResponseHeaders
, it still deploys via CloudFormation, but when the Amplify build runs I get the errors below.Regression Issue
Last Known Working CDK Version
No response
Expected Behavior
The app deploys successfully on Amplify.
Current Behavior
The app errors on Amplify deploy:
Reproduction Steps
Example Amplify app:
Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.162.1 (build 10aa526)
Framework Version
2.162.1-alpha.0
Node.js Version
v22.9.0
OS
macOS 14.7 (23H124)
Language
TypeScript
Language Version
TypeScript 5.6.3
Other information
No response
The text was updated successfully, but these errors were encountered: