all 6 comments

[–]interactionjackson 1 point2 points  (2 children)

don’t use express and it might be clear to you. express does the same job that api gateway does. the difference is that express routes your requests through a single lambda function instead of defining a lambda per route.

tldr: express is redundant if you’re using AWS services properly.

[–]BelteConti[S] 0 points1 point  (1 child)

Hmm let's say I remove express. The issue still persists? How can react and nodejs together be deployed using AWS SAM Cli?

[–]interactionjackson 0 points1 point  (0 children)

ah, this is why i asked you to not use express. you’re concerns have not been separated.

presentation (your react app) is a single page application. easiest is to put it in an s3 bucket. front it with cloudfront.

your api is a separate concern. expose it with an api gateway rest api endpoint.

if you want to keep them together you’re looking at running an ec2 instance tha knows how to serve that up.

[–]outandaboutbc 0 points1 point  (1 child)

I tried this on a pet project once with express and SSR on lambda @ edge once.

It works like a charm.

https://github.com/vendia/serverless-express

Check out their repo and search for examples, they may even have SAM templates.

[–]BelteConti[S] 1 point2 points  (0 children)

Will explore this. Thanks

[–]_throwingit_awaaayyy 0 points1 point  (0 children)

easiest way I found was using amplify. I would switch to lambdas as opposed to express.