lift icon indicating copy to clipboard operation
lift copied to clipboard

[Static Website] Point /api to the serverless gateway

Open kasperpihl opened this issue 3 years ago • 2 comments

Could it make sense to have an option to forward /api in the cloudfront distribution to the api gateway?

This would avoid Preflight overhead and making it easy to talk with the serverless api from the website

PS. Absolutely LOVE this. Thanks for doing the heavy lifting!

kasperpihl avatar Jul 30 '21 11:07 kasperpihl

Hi, thanks for the feedback and the suggestion!

Just to clarify, at the moment the pattern we support is:

  • deploy a static website with a domain (as a construct)
  • deploy an API separately, with a different domain (via traditional serverless.yml APIs)

I'm personally a bit wary of adding the feature you mention: theoretically it sounds simple. But I'm afraid of the complexity we don't immediately see, e.g. features on the /api path we may need to support once we go down this path (for example configuring CloudFront caching).

What would help here is:

  • list and quantify precisely the downsides of the current pattern (i.e. having 2 separate domains)

    For example, what is the actual overhead you mention? Is this a problem for 90% of projects, or only 10% (e.g. super large websites)? Are there any other downsides we haven't listed here?

  • list the features we might want to support if the API option was added to the static-website construct

    The goal here would be to be as complete as possible. This wouldn't be a list of things to implement immediately, but rather a way to anticipate the scope of the feature long term.

@kasperpihl these questions are not necessarily for you :), it's for whoever wants to move that issue forward in the future.

mnapoli avatar Aug 03 '21 08:08 mnapoli

I found a project that includes the /api route, but it's still would be great if lift can support it. https://www.madskills.io/fullstack-serverless/

ianzone avatar Feb 27 '22 15:02 ianzone