apache.conf 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <VirtualHost *:80>
  2. ServerName localhost
  3. DocumentRoot /var/www/html/frontend/dist
  4. # Serve Vue.js frontend (SPA)
  5. <Directory /var/www/html/frontend/dist>
  6. AllowOverride All
  7. Require all granted
  8. # Handle Vue.js routing - redirect all non-file requests to index.html
  9. RewriteEngine On
  10. RewriteCond %{REQUEST_FILENAME} !-f
  11. RewriteCond %{REQUEST_FILENAME} !-d
  12. RewriteRule . /index.html [L]
  13. </Directory>
  14. # Handle PHP API endpoints
  15. <Directory "/var/www/html/api">
  16. AllowOverride All
  17. Require all granted
  18. Options -Indexes
  19. </Directory>
  20. # Enable CORS for API endpoints
  21. <Directory "/var/www/html/api">
  22. Header set Access-Control-Allow-Origin "*"
  23. Header set Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS"
  24. Header set Access-Control-Allow-Headers "Content-Type, Authorization, X-Requested-With"
  25. </Directory>
  26. # Handle OPTIONS requests for CORS
  27. <FilesMatch "\.php$">
  28. SetEnvIf Request_Method "OPTIONS" CORs
  29. </FilesMatch>
  30. <IfModule mod_headers.c>
  31. Header always set Access-Control-Allow-Origin "*" env=CORs
  32. Header always set Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS" env=CORs
  33. Header always set Access-Control-Allow-Headers "Content-Type, Authorization, X-Requested-With" env=CORs
  34. </IfModule>
  35. # API endpoint routing
  36. Alias /api /var/www/html/api
  37. # Handle uploads directory
  38. Alias /uploads /var/www/html/uploads
  39. <Directory "/var/www/html/uploads">
  40. AllowOverride All
  41. Require all granted
  42. Options -Indexes
  43. </Directory>
  44. ErrorLog ${APACHE_LOG_DIR}/error.log
  45. CustomLog ${APACHE_LOG_DIR}/access.log combined
  46. </VirtualHost>