refont back express
This commit is contained in:
16
backend/config/cors.js
Normal file
16
backend/config/cors.js
Normal file
@@ -0,0 +1,16 @@
|
||||
import dotenv from 'dotenv';
|
||||
import * as path from "node:path";
|
||||
|
||||
const envFile = `.env`;
|
||||
dotenv.config({ path: path.resolve(process.cwd(), envFile), override: true });
|
||||
|
||||
const allowedOrigin = process.env.ALLOWED_ORIGIN || 'http://localhost:4200';
|
||||
|
||||
const corsOptions = {
|
||||
origin: allowedOrigin,
|
||||
methods: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS'],
|
||||
allowedHeaders: ['Content-Type', 'Authorization'],
|
||||
credentials: true,
|
||||
};
|
||||
|
||||
export default corsOptions;
|
||||
13
backend/config/db.js
Normal file
13
backend/config/db.js
Normal file
@@ -0,0 +1,13 @@
|
||||
import mariadb from 'mariadb';
|
||||
import dotenv from 'dotenv';
|
||||
|
||||
dotenv.config();
|
||||
|
||||
const pool = mariadb.createPool({
|
||||
host: process.env.DB_HOST,
|
||||
user: process.env.DB_USER,
|
||||
password: process.env.DB_PASSWORD,
|
||||
database: process.env.DB_DATABASE
|
||||
});
|
||||
|
||||
export default pool;
|
||||
Reference in New Issue
Block a user