Skip to content

Environment Vars Not Working #43

Description

@matt-lethargic

I'm trying to get environment variables working as described in the documentation but not having any lucky.

serverless.yml

service:
name: library

provider:
  name: cloudflare
  stage: systest
  config:
    accountId: <somestring>
    zoneId: <anotherstirng>
  environment:
    MY_TEST: HELLO

plugins:
  - serverless-cloudflare-workers

functions:
  library:
    name: library
    script: handlers/test
    environment:
      MY_TEST: WORLD
    events:
      - http:
        url: docs.somedomain.com/*
        method: GET

test.js

addEventListener('fetch', event => {
  event.respondWith(handle(event))
})

async function handle(event) {

  console.log('MY_TEST: ', process.env.MY_TEST);

  return new Response(null, { status: 200 });
}

I've tried process.env.MY_TEST and just plain old MY_TEST and no luck.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions