We would like to use the same domain for API Gatew...
# help
j
We would like to use the same domain for API Gateway and StaticSite: example.com - site example.com/api - api I just naively tried to set the same customDomain (+
path: 'api'
on gateway) and not suprisingly it fails with: jplacek-talsec-talsec | CREATE_FAILED | AWS:Route53:RecordSet | WebAliasRecord22320298 | [Tried to create resource record set [name='xxx.xxx.', type='A'] but it already exists] Is this somehow (easily) achievable with SST?
c
why don’t you try
Copy code
<http://example.com|example.com> - site
<http://api.example.com|api.example.com> - api
I think that’d solve your problem
j
Because it's not my decision. The partial motivation is to avoid the CORS configuration for production/integration env.
c
ahh ok, I don’t know how to sort that out then. but I’ll keep an eye here to see if I can learn something
j
Copy code
cfDistribution: {
        additionalBehaviors: {
          '/api/*': {
            origin: new HttpOrigin(api.url),
          },
        }
      },
Am I on the right track?
One problem is, that origin must be hostname and I don't know how to strip
https
from
api.url
, because it's a token (not avaiable at build time).
Fn.parseDomainName(api.httpApi.apiEndpoint)
f
@Jan Plaček did
Fn.parseDomainName(api.httpApi.apiEndpoint)
work?
I was going to suggest using CloudFormation intrinsic function
Fn.split
, but didn’t know about
Fn.arseDomainName
😂
j
Yes it does work. I was also going for split+select at first, but then noticed this handy function. Probably not the first one needing it 🙂