https://serverless-stack.com/ logo
#help
Title
# help
k

Kujtim Hoxha

05/25/2022, 4:52 PM
Hey there, is there any way you could setup your API to run under
<http://yourdomain.com/api|yourdomain.com/api>
and you static site under
<http://yourdomain.com|yourdomain.com>
, I am asking because this way I would prevent cors and preflight (OPTION) calls
m

manitej

05/25/2022, 4:55 PM
k

Kujtim Hoxha

05/25/2022, 5:01 PM
I could try that… what I am concerned is that StaticSite uses CF and points the route 53 record to the CF and since it would be the same record (I am assuming) in route 53 it would not work…
d

Derek Kershner

05/25/2022, 5:27 PM
I recommend against this, for lots of reasons including local development (which is a key SST differentiator), but you would need to place the StaticSite CloudFront in front of the Api using a custom behavior for the path.
k

Kujtim Hoxha

05/25/2022, 5:28 PM
Yeah you are right the other thing that is weird is that I enabled caching for the preflight but for some reason the browser is ignoring it 🤷‍♂️
d

Derek Kershner

05/25/2022, 5:29 PM
Relying on the browser is always gonna be a crapshoot, but you should be able to do something cachelike in your backend.
ApiGateway HTTP does it fairly automatically.
k

Kujtim Hoxha

05/25/2022, 5:30 PM
Yeah i was hoping to prevent that unnecessary round trip for the options call
d

Derek Kershner

05/25/2022, 5:31 PM
Sure, worth trying to fix to be sure.
k

Kujtim Hoxha

05/25/2022, 5:31 PM
Either way not really a big deal was mostly wondering but you are right that can come with other issues
d

Derek Kershner

05/25/2022, 5:32 PM
And costs (cft now part of your API)
k

Kujtim Hoxha

05/25/2022, 5:33 PM
Yeah 100%