ulaan
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
require('dotenv').config({ path: require('path').join(__dirname, '../.env') });
|
||||
const express = require('express');
|
||||
const session = require('express-session');
|
||||
const helmet = require('helmet');
|
||||
// const helmet = require('helmet'); // Geçici olarak devre dışı
|
||||
const cors = require('cors');
|
||||
const logger = require('./config/logger');
|
||||
const sessionConfig = require('./config/session');
|
||||
@@ -12,12 +12,8 @@ const { apiLimiter } = require('./middlewares/rateLimiter');
|
||||
const app = express();
|
||||
const PORT = process.env.PORT || 3000;
|
||||
|
||||
// Security middleware - CSP'yi devre dışı bırak (CORS ve mixed content sorunları için)
|
||||
app.use(helmet({
|
||||
contentSecurityPolicy: false, // CSP'yi tamamen kapat
|
||||
crossOriginEmbedderPolicy: false,
|
||||
crossOriginResourcePolicy: { policy: "cross-origin" },
|
||||
}));
|
||||
// Security middleware - Helmet'i tamamen kaldır (CORS ve mixed content sorunları için)
|
||||
// app.use(helmet()); // Geçici olarak devre dışı
|
||||
|
||||
// CORS - Her yerden erişime izin ver (tüm route'larda)
|
||||
app.use((req, res, next) => {
|
||||
@@ -49,11 +45,19 @@ app.use(express.urlencoded({ extended: true }));
|
||||
// Serve static files (landing page and frontend build)
|
||||
const path = require('path');
|
||||
app.use(express.static(path.join(__dirname, 'public'), {
|
||||
setHeaders: (res, path) => {
|
||||
// CORS headers for static files
|
||||
setHeaders: (res, filePath) => {
|
||||
// CORS headers for ALL static files (CSS, JS, images, etc.)
|
||||
res.set('Access-Control-Allow-Origin', '*');
|
||||
res.set('Access-Control-Allow-Methods', 'GET, OPTIONS');
|
||||
res.set('Access-Control-Allow-Headers', 'Content-Type');
|
||||
res.set('Access-Control-Allow-Headers', 'Content-Type, Accept, Origin');
|
||||
res.set('Access-Control-Allow-Credentials', 'true');
|
||||
|
||||
// Content-Type header'larını doğru ayarla
|
||||
if (filePath.endsWith('.js')) {
|
||||
res.set('Content-Type', 'application/javascript; charset=utf-8');
|
||||
} else if (filePath.endsWith('.css')) {
|
||||
res.set('Content-Type', 'text/css; charset=utf-8');
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
|
||||
@@ -4,6 +4,17 @@ import react from '@vitejs/plugin-react'
|
||||
// https://vite.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
// Build output will be copied to backend in Dockerfile
|
||||
// For local development, keep default dist/ directory
|
||||
base: '/', // Base path - root'tan servis edilecek
|
||||
build: {
|
||||
assetsDir: 'assets',
|
||||
// Relative path'ler kullan (absolute değil)
|
||||
rollupOptions: {
|
||||
output: {
|
||||
// Asset dosyaları için relative path
|
||||
assetFileNames: 'assets/[name]-[hash][extname]',
|
||||
chunkFileNames: 'assets/[name]-[hash].js',
|
||||
entryFileNames: 'assets/[name]-[hash].js',
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user