- three.js GLTFLoader 는 glb 안 이미지를 blob: 주소로 fetch 해 읽는데 connect-src 가 막아 텍스처가 모두 실패했다 (요원 흰색, 두 층 맵 재질은 텍스처 실패로 맵 전체가 실패 → 미니맵 바닥) - CSP 를 csp.ts 하나로 모으고 vite preview 도 같은 CSP 로 열어 헤드리스 확인이 실제와 같은 제한에서 되게 함 - 맵 B 층 텍스처 하나를 못 읽어도 맵 전체를 버리지 않음 - 시험: connect-src 에 blob: 확인 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
27 lines
1.4 KiB
TypeScript
27 lines
1.4 KiB
TypeScript
import { defineConfig } from 'vite';
|
|
import react from '@vitejs/plugin-react';
|
|
import { fileURLToPath } from 'node:url';
|
|
import { contentSecurityPolicy } from '../server/src/csp';
|
|
|
|
const sharedSrc = fileURLToPath(new URL('../../packages/shared/src/index.ts', import.meta.url));
|
|
// 목 서버(mock/server.mjs) 주소. 실제 배포에서는 사이트 서버가 같은 오리진으로 정적 파일을 서빙한다.
|
|
const backend = process.env.GVR_BACKEND ?? 'http://127.0.0.1:18787';
|
|
const proxy = {
|
|
'/api': { target: backend, changeOrigin: false },
|
|
'/auth': { target: backend, changeOrigin: false },
|
|
'/game-assets': { target: backend, changeOrigin: false },
|
|
'/mock': { target: backend, changeOrigin: false },
|
|
'/site': { target: backend, changeOrigin: false },
|
|
'/ws': { target: backend.replace(/^http/, 'ws'), ws: true },
|
|
};
|
|
|
|
export default defineConfig({
|
|
base: '/',
|
|
plugins: [react()],
|
|
resolve: { alias: { '@gvr/shared': sharedSrc } },
|
|
server: { port: 5173, host: '127.0.0.1', proxy, fs: { allow: ['.', '../../packages/shared'] } },
|
|
// 미리보기(빌드 결과)는 실제 사이트와 같은 CSP 로 연다 (dev 는 vite 가 인라인 스크립트를 넣어 못 씀)
|
|
preview: { port: 4173, host: '127.0.0.1', proxy, headers: { 'content-security-policy': contentSecurityPolicy('ws://127.0.0.1:4173') } },
|
|
build: { outDir: 'dist', sourcemap: false, chunkSizeWarningLimit: 900 },
|
|
});
|