# CORS 설정
Header always set Access-Control-Allow-Origin "*"
Header always set Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS"
Header always set Access-Control-Allow-Headers "Content-Type, Authorization, X-Requested-With, Origin, Accept"
Header always set Access-Control-Max-Age "86400"

# OPTIONS 요청에 대한 응답
RewriteEngine On
RewriteCond %{REQUEST_METHOD} OPTIONS
RewriteRule ^(.*)$ $1 [R=200,L]

# Board routing - FAQ
RewriteRule ^board_list/faq$ backend/index.php?/board_list/faq [L,QSA]

# Board routing - Media (News, Press)
RewriteRule ^board_list/media$ backend/index.php?/board_list/media [L,QSA]

# Board routing - Media SNS
RewriteRule ^board_list/media_sns$ backend/index.php?/board_list/media_sns [L,QSA]

# Board routing - Technology (Patents)
RewriteRule ^board_list/technology1$ backend/index.php?/board_list/technology1 [L,QSA]
RewriteRule ^board_list/technology2$ backend/index.php?/board_list/technology2 [L,QSA]
RewriteRule ^board_list/technology3$ backend/index.php?/board_list/technology3 [L,QSA]
RewriteRule ^board_list/technology4$ backend/index.php?/board_list/technology4 [L,QSA]

# Backend upload 이미지 접근 허용
RewriteRule ^backend/upload/(.*)$ backend/upload/$1 [L]

# /api/ 경로는 CodeIgniter로 라우팅
RewriteCond %{REQUEST_URI} ^/api/(.*)$
RewriteRule ^api/(.*)$ /api/index.php/$1 [L,QSA]

# /api/ 경로의 정적 파일들 (images, assets, upload 등)
RewriteCond %{REQUEST_URI} ^/api/(images|asset|upload)/(.*)$
RewriteRule ^api/(.*)$ /api/$1 [L]

# 나머지는 Nuxt.js로 (실제 운영에서는 Nginx/Apache가 처리)
# 개발 환경에서는 npm run dev가 처리함