interview-assistant/nginx.conf
nokker a75bacea5e Implement secure N8N webhook integration and resolve CORS issues
### 🔧 Technical Solution
- **API Key Authentication**: Migrated from Authelia session auth to X-N8N-API-KEY header authentication
- **CORS Resolution**: Eliminated preflight failures by removing authentication redirects from webhook endpoints
- **Error Handling**: Added graceful fallback for empty N8N responses with intelligent question generation
- **Type Safety**: Updated TypeScript interfaces for enhanced response format support

### 🛡️ Security Enhancements
- **Maintained Security**: N8N UI still protected by Authelia while webhooks use API key authentication
- **Audit Trail**: All webhook requests logged with API key identification for security monitoring
- **Rate Limiting**: Applied through Traefik middleware to prevent API abuse
- **Easy Key Rotation**: API keys can be changed instantly without affecting user sessions

### 📱 Application Updates
- **N8nSyncService**: Complete migration from Authelia to API key authentication
- **CV Upload Component**: Simplified flow without authentication popups for N8N integration
- **Fallback System**: Intelligent question generation based on CV content when N8N unavailable
- **User Experience**: Seamless PDF upload to analysis workflow without CORS barriers

### 🐳 Docker Configuration
- **Multi-stage Build**: Optimized Dockerfile with Node.js 20 and nginx:alpine
- **Docker Compose**: Complete service orchestration with port 3007 mapping
- **Nginx Configuration**: Custom MIME types for PDF.js worker files and SPA routing
- **SSL Integration**: Traefik labels for automatic HTTPS with proper CORS headers

### 🧪 Testing Results
-  **PDF Processing**: Successfully extracts text from uploaded CVs (2871+ characters)
-  **CORS Success**: OPTIONS and POST requests work without authentication redirects
-  **Webhook Integration**: Connects to N8N with X-N8N-API-KEY header
-  **Fallback Questions**: Generates contextual questions when N8N workflow unavailable
-  **Type Safety**: No TypeScript compilation errors with updated interfaces

### 💡 Intelligent Fallback Features
- **Technical Questions**: Generated based on actual CV skills (e.g., JavaScript experience)
- **Behavioral Questions**: Standard problem-solving and teamwork assessments
- **Experience-Specific**: Company and role-specific questions from work history
- **Career Development**: Growth and motivation questions tailored to experience level

### 🔗 Integration Points
- **Environment Config**: Added N8N API key and base URL configuration
- **Service Communication**: Direct HTTP with API key headers (no session dependency)
- **Response Handling**: Support for both N8N workflow responses and local fallback
- **Error Recovery**: Graceful degradation when external services unavailable

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-17 21:38:22 +02:00

118 lines
4.8 KiB
Nginx Configuration File

events {
worker_connections 1024;
}
http {
# Define MIME types including .mjs
types {
text/html html htm shtml;
text/css css;
text/xml xml;
image/gif gif;
image/jpeg jpeg jpg;
application/javascript js mjs;
application/atom+xml atom;
application/rss+xml rss;
text/mathml mml;
text/plain txt;
text/vnd.sun.j2me.app-descriptor jad;
text/vnd.wap.wml wml;
text/x-component htc;
image/png png;
image/tiff tif tiff;
image/vnd.wap.wbmp wbmp;
image/x-icon ico;
image/x-jng jng;
image/x-ms-bmp bmp;
image/svg+xml svg svgz;
image/webp webp;
application/font-woff woff;
application/java-archive jar war ear;
application/json json;
application/mac-binhex40 hqx;
application/msword doc;
application/pdf pdf;
application/postscript ps eps ai;
application/rtf rtf;
application/vnd.apple.mpegurl m3u8;
application/vnd.ms-excel xls;
application/vnd.ms-fontobject eot;
application/vnd.ms-powerpoint ppt;
application/vnd.wap.wmlc wmlc;
application/vnd.google-earth.kml+xml kml;
application/vnd.google-earth.kmz kmz;
application/x-7z-compressed 7z;
application/x-cocoa cco;
application/x-java-archive-diff jardiff;
application/x-java-jnlp-file jnlp;
application/x-makeself run;
application/x-perl pl pm;
application/x-pilot prc pdb;
application/x-rar-compressed rar;
application/x-redhat-package-manager rpm;
application/x-sea sea;
application/x-shockwave-flash swf;
application/x-stuffit sit;
application/x-tcl tcl tk;
application/x-x509-ca-cert der pem crt;
application/x-xpinstall xpi;
application/xhtml+xml xhtml;
application/xspf+xml xspf;
application/zip zip;
application/octet-stream bin exe dll;
application/octet-stream deb;
application/octet-stream dmg;
application/octet-stream iso img;
application/octet-stream msi msp msm;
audio/midi mid midi kar;
audio/mpeg mp3;
audio/ogg ogg;
audio/x-m4a m4a;
audio/x-realaudio ra;
video/3gpp 3gpp 3gp;
video/mp2t ts;
video/mp4 mp4;
video/mpeg mpeg mpg;
video/quicktime mov;
video/webm webm;
video/x-flv flv;
video/x-m4v m4v;
video/x-mng mng;
video/x-ms-asf asx asf;
video/x-ms-wmv wmv;
video/x-msvideo avi;
}
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
index index.html;
# Handle Angular routing
location / {
try_files $uri $uri/ /index.html;
}
# Security headers
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-XSS-Protection "1; mode=block" always;
# Enable gzip compression
gzip on;
gzip_comp_level 6;
gzip_types
text/plain
text/css
text/xml
text/javascript
application/javascript
application/xml+rss
application/json;
}
}