Skip to content

Environment Vars Not Working #43

@matt-lethargic

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.

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