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

env variables not passed into serverless-offline while debugging with visual studio #1773

Open
robertlario opened this issue Mar 29, 2024 · 0 comments

Comments

@robertlario
Copy link

Bug Report

Current Behavior
env set in launch.json are not set in process.env.

Sample Code
file: launch.json
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
//"program": "${workspaceFolder}/node_modules/serverless/bin/serverless",
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${userHome}/AppData/Roaming/npm/node_modules/serverless/bin/serverless",
"args": [
"offline",
"start",
"--httpPort",
"4000",
"--noTimeout",
],
"runtimeExecutable": "node",
"runtimeArgs": [
"--preserve-symlinks-main",
"--preserve-symlinks"
],
"stopOnEntry": true,
"env": {"MYVAR": "value"}
}
]
}

Sample Code
file: handler.js
module.exports.hello = async (event) => {
const { MYVAR} = process.env;
return {
statusCode: 200,
body: JSON.stringify('Hello ' + robert )
};
};

Sample Code
file: serverless.yml
service: roberts

frameworkVersion: '3'

provider:
name: aws
runtime: nodejs18.x

plugins:

  • serverless-offline

functions:
hello:
handler: handler.hello
events:
- http:
path: /hello
method: get
cors: true

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

No branches or pull requests

1 participant