Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
ℹ️ Issue
Closes no ticket
📝 Description
I found that the cors error was not because cors was setup wrong on the aws side of things, but because the backend was crashing as soon as the website was accessed, and the error headers did not include cors. To fix this, I added cors to the response headers for errors, and I started looking into why the crash was happening. The primary cause seemed to be a difference in the version of the aws-sdk used by this project and what is included in Lambda by default.
Addressing this required us to change how Lambda accessed dependencies. To this end, I made a few changes.
If you add new dependencies to the application, you'll have to make sure it is included in the lambda layers. There are two options for how to do this. You can either update the existing layer, or you can keep the two layers I have already added and put new dependencies into new layers. Either way, the steps will look something like the following:
cd backendrm -rf deps-layer deps-layer.zipmkdir -p deps-layer/nodejscp package.json deps-layer/nodejs/cd deps-layer/nodejsnpm install --omit=dev --productioncd ../../deps-layerzip -r ../deps-layer.zip .You can then upload this zip file to lambda:
Go to Lambda on AWS, select Layers, and click on
bcan-dependencies, or add a new layer if that is the approach you decide to go with.Click create version.
Upload the zip file you generated above, then select node 22 as the runtime.
A secondary issue that I think was causing it to crash was there was no
auth/sessionroute, I added that too.✔️ Verification
I ensued I could login from the deployed url
Test Changes
No test changes.
🏕️ (Optional) Future Work / Notes
I changed some of the deploy scripts, but you should still be able to deploy with
npm run deploy.