Increase security - move host locations to .env
This commit is contained in:
parent
f4e784b2ec
commit
e2f2edbf59
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@ -41,7 +41,7 @@
|
||||
// ============================
|
||||
"[javascript]": { "editor.defaultFormatter": "vscode.typescript-language-features" },
|
||||
"[javascriptreact]": { "editor.defaultFormatter": "vscode.typescript-language-features" },
|
||||
"[typescript]": { "editor.defaultFormatter": "esbenp.prettier-vscode" },
|
||||
"[typescript]": { "editor.defaultFormatter": "vscode.typescript-language-features" },
|
||||
"[typescriptreact]": { "editor.defaultFormatter": "vscode.typescript-language-features" },
|
||||
|
||||
// ============================
|
||||
|
||||
@ -6,11 +6,8 @@ const User = require("./models/user.model");
|
||||
const app = express();
|
||||
app.use(express.json());
|
||||
|
||||
const allowedOrigins = [
|
||||
"http://localhost:3000",
|
||||
"https://costco.nicosaya.com",
|
||||
"https://costco.api.nicosaya.com",
|
||||
];
|
||||
const allowedOrigins = process.env.ALLOWED_ORIGINS.split(",").map(origin => origin.trim());
|
||||
console.log("Allowed Origins: ", allowedOrigins);
|
||||
app.use(
|
||||
cors({
|
||||
origin: function (origin, callback) {
|
||||
|
||||
@ -12,6 +12,7 @@ import PrivateRoute from "./utils/PrivateRoute.jsx";
|
||||
|
||||
import RoleGuard from "./utils/RoleGuard.jsx";
|
||||
|
||||
console.log("VITE_ALLOWED_HOSTS:", import.meta.env.VITE_ALLOWED_HOSTS);
|
||||
|
||||
function App() {
|
||||
return (
|
||||
|
||||
@ -72,7 +72,7 @@ export default function GroceryList() {
|
||||
let newQuantity = quantity;
|
||||
|
||||
const item = await getItemByName(itemName);
|
||||
if (item.data) {
|
||||
if (item.data && item.data.item_bought === false) {
|
||||
let currentQuantity = item.data.quantity;
|
||||
const yes = window.confirm(
|
||||
`Item "${itemName}" already exists in the list. Do you want to update its quantity from ${currentQuantity} to ${currentQuantity + newQuantity}?`
|
||||
|
||||
@ -1,10 +1,15 @@
|
||||
import { defineConfig } from 'vite'
|
||||
import react from '@vitejs/plugin-react'
|
||||
import react from '@vitejs/plugin-react';
|
||||
import { defineConfig, loadEnv } from 'vite';
|
||||
|
||||
const env = loadEnv('', process.cwd());
|
||||
const allowedHosts = env.VITE_ALLOWED_HOSTS
|
||||
? env.VITE_ALLOWED_HOSTS.split(',').map((host) => host.trim())
|
||||
: [];
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
server: {
|
||||
allowedHosts: ["costco.nicosaya.com", "www.costco.nicosaya.com"],
|
||||
allowedHosts: allowedHosts,
|
||||
watch: {
|
||||
usePolling: true,
|
||||
},
|
||||
|
||||
Loading…
Reference in New Issue
Block a user