From c62771b6c744af9737d9d57bef76fd6f8a429960 Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 7 Dec 2023 15:23:02 +0100 Subject: [PATCH] refs #6274 dotenv added --- .env.example | 1 + .gitignore | 3 ++- package-lock.json | 12 ++++++++++++ package.json | 1 + proxy.js | 5 +++-- 5 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..3e0d362 --- /dev/null +++ b/.env.example @@ -0,0 +1 @@ +TARGET='url del servidor local' \ No newline at end of file diff --git a/.gitignore b/.gitignore index b512c09..1dcef2d 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -node_modules \ No newline at end of file +node_modules +.env \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 5e61de4..243c2ae 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,6 +9,7 @@ "version": "1.0.2", "license": "GPL-3.0", "dependencies": { + "dotenv": "^16.3.1", "fastclick": "^1.0.6", "jquery": "^3.7.0" }, @@ -195,6 +196,17 @@ "npm": "1.2.8000 || >= 1.4.16" } }, + "node_modules/dotenv": { + "version": "16.3.1", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.3.1.tgz", + "integrity": "sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/motdotla/dotenv?sponsor=1" + } + }, "node_modules/ee-first": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", diff --git a/package.json b/package.json index ccf3517..b96ffbe 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "npm": ">=8" }, "dependencies": { + "dotenv": "^16.3.1", "fastclick": "^1.0.6", "jquery": "^3.7.0" }, diff --git a/proxy.js b/proxy.js index defde31..3d3085b 100644 --- a/proxy.js +++ b/proxy.js @@ -1,10 +1,11 @@ const express = require('express'); +const dotenv = require('dotenv'); const { createProxyMiddleware } = require('http-proxy-middleware'); const app = express(); - +dotenv.config(); const apiProxy = createProxyMiddleware('/api', { - target: 'http://localhost:3000', + target: process.env.TARGET, changeOrigin: true, });