dherault / dherault/serverless-offline

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

Open
#1,773 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
5.3k
Forks
811
Avg merge
2d 4h
Merged PRs (30d)
3

Description

## 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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.