webiny-js icon indicating copy to clipboard operation
webiny-js copied to clipboard

Don’t add Host header on admin/api custom domains

Open Pavel910 opened this issue 3 years ago • 0 comments

Version

Presumably all >=5.29.0 are affected.

What are the steps to reproduce this bug?

Create a project and apply a custom domain to admin and api apps, following the tutorial on connecting a custom domain to the website app: https://www.webiny.com/docs/infrastructure/additional-resources/connect-custom-domain (do the same changes, but in the apps/admin or in apps/api apps, instead of the apps/website).

What is the expected behavior?

Admin app (or API) is accessible via the configured custom domain.

What do you see instead?

A certificate error similar to this:

CleanShot 2022-09-16 at 18 28 09

Possible solution

First, we need to upgrade the applyCustomDomain utility, and remove the addition of the Host header, specifically this chunk of code: https://github.com/webiny/webiny-js/blob/next/packages/pulumi-aws/src/apps/customDomain.ts#L15-L25

Secondly, we need to move the chunk removed in the previous step to the website app only, since it's the only app using Lambda@Edge and thus needs that header to be forwarded by the Cloudfront distribution. That chunk should be placed after this line: https://github.com/webiny/webiny-js/blob/next/packages/pulumi-aws/src/apps/website/createWebsitePulumiApp.ts#L186, and applied to the deliveryCloudfront distribution.

Testing

Testing of this is a bit tricky, because you need to have a custom domain, and create an ACM certificate. Webiny team will help you test this as soon as you open a PR :)

Pavel910 avatar Sep 16 '22 16:09 Pavel910