Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CORS policy error after login #50

Open
MASalem opened this issue Mar 17, 2021 · 1 comment
Open

CORS policy error after login #50

MASalem opened this issue Mar 17, 2021 · 1 comment
Labels

Comments

@MASalem
Copy link

MASalem commented Mar 17, 2021

Hello,

After deploying the webapp, when I sign up and then login, the page that is in the screenshot (attached) appears briefly then I get redirected to the login page again.
image

This seem to be an issue with the CORS policy, do you know how I can solve this?

Thank you!

Reproduction Steps

Error Log

Environment

  • SAM CLI Version :
  • OS :
  • Language :

Other


This is 🐛 Bug Report

@MASalem MASalem added the bug label Mar 17, 2021
@Iviglious
Copy link

Hi,

In summary

The CORS error is a secondary error caused by a previous error of a missing package (aws-xray-sdk-core) in AWS Lambda.

Workaround fix

Generate local installation of all packages (libraries) and then deploy them together in AWS Lambda.

In details

When checking the CloudWatch logs of the AWS Lambda functions It can be seen the error of a missing package/library aws-xray-sdk-core:

2021-03-23T00:17:07.587Z	undefined	ERROR	Uncaught Exception 	{
    "errorType": "Runtime.ImportModuleError",
    "errorMessage": "Error: Cannot find module 'aws-xray-sdk-core'\nRequire stack:\n- /var/task/app.js\n- /var/runtime/UserFunction.js\n- /var/runtime/index.js",
    "stack": [
        "Runtime.ImportModuleError: Error: Cannot find module 'aws-xray-sdk-core'",
        "Require stack:",
        "- /var/task/app.js",
        "- /var/runtime/UserFunction.js",
        "- /var/runtime/index.js",
        "    at _loadUserApp (/var/runtime/UserFunction.js:100:13)",
        "    at Object.module.exports.load (/var/runtime/UserFunction.js:140:17)",
        "    at Object.<anonymous> (/var/runtime/index.js:43:30)",
        "    at Module._compile (internal/modules/cjs/loader.js:999:30)",
        "    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)",
        "    at Module.load (internal/modules/cjs/loader.js:863:32)",
        "    at Function.Module._load (internal/modules/cjs/loader.js:708:14)",
        "    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)",
        "    at internal/main/run_main_module.js:17:47"
    ]
}

Currently the AWS Lambda functions only require/depend on these 3 packages:

    "aws-sdk": "^2.823.0",
    "aws-embedded-metrics": "^2.0.2",
    "aws-xray-sdk-core": "^3.2.0"

The aws-sdk seems to be already included in AWS Lambda (no error about it). However, the xray library seems to be missing (or there is some internal bug).
I tested with NodeJS 14 version of AWS Lambda and the xray library was not available there either.

Workaround fix

I did npm install inside the todo-src\getAllTodo folder then did another sam deploy and it was fine.
The CORS error disappeared.
I created a bash script to do the install of the libraries in all function folders:

cd todo-src/

cd addTodo; npm install; cd ..
cd completeTodo; npm install; cd ..
cd deleteTodo; npm install; cd ..
cd getAllTodo; npm install; cd ..
cd getTodo; npm install; cd ..
cd updateTodo; npm install; cd ..

cd ..

Feedback

  1. Check with the AWS Lambda team on why the aws-xray-sdk-core library is not available.
  2. Furthermore, it will be useful to expand/update this page: https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html and give detailed list of all libraries/packages and their version supported by AWS Lambda.
  3. Deploying the whole installation of packages is not user friendly as the code gets zipped and is not visible in AWS portal.

Regards,
Iviglious

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants