Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cors-env

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cors-env

Set and Loads environment variables from .env file across platforms

  • 1.0.2
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

corsenv

CorsEnv

Corsenv is a zero-dependency module that loads environment variables from a .env file into process.env. Storing configuration in the environment separate from code is based on The Twelve-Factor App methodology.

Install

install locally (recommended) npm install cors-env --save Or installing with yarn? yarn add cors-env

Usage

Usage is easy!

  1. Create a .env file in the root directory of your project. .env file

    Add environment-specific variables on new lines in the form of NAME=VALUE

    DB_HOST=localhost

    DB_USER=root

    DB_PASS=s1mpl3

  2. As early as possible in your application, import and configure dotenv. // index.js require('cors-env').config()

    console.log(process.env) // remove this after you've confirmed it working

    .. or using ES6?

    // index.mjs (ESM) import 'dotenv/config'; import express from 'express';

  3. That's it! 🎉

    process.env now has the keys and values you defined in your .env file.

    require('cors-env').config()

    ...

    const db = require('db') db.connect({ host: process.env.DB_HOST, username: process.env.DB_USER, password: process.env.DB_PASS })

Keywords

FAQs

Package last updated on 14 Jul 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc