Open sonerkuyar opened 3 days ago
Problem can be seen due to different reasons but no solutions works for me at different discussions Swagger issue
/static/...
were serving the React app's files instead of the Swagger files./api/static/
and frontend files under /static/
. However, the issue persisted because the backend was still generating static file URLs starting with /static/
, which conflicted with the React app./api/static/
without updating the Django STATIC_URL
caused inconsistencies because the backend was still pointing to /static/
.Updated the STATIC_URL
setting in settings.py
to /api/static/
:
STATIC_URL = '/api/static/'
This ensured that all backend static files were served under /api/static/
.
Ran the collectstatic
command to collect all static files into the correct directory:
python manage.py collectstatic
Adjusted the Nginx configuration to serve backend static files from /api/static/
:
location /api/static/ {
alias /root/bounswe2024group12/app/backend/staticfiles/; # Adjusted to the actual path
expires 1y; # Cache files for better performance
access_log off;
}
Restarted Nginx to apply the changes:
sudo systemctl reload nginx
I've made appropriate changes at deployment machine and fixed the error.
Description
When accessing Swagger UI at
/api/swagger/
, the required static files (e.g.,swagger-ui-bundle.js
) were not loading correctly. Instead, the React app's static files were being served, causing the following error:This occurred because both the frontend and backend static files were being served from the same path (
/static/
), leading to a conflict.Acceptance Criteria
...
Reviewer:
This issue will be reviewed by: @ounuvar @ozankaymak