Hi,
I have been trying to get this set up for about two months now but keep punting because I get stuck. I am trying to get my Django DRF + Vue application deployed to production and tried two different solutions:
1) Deploying Django to a server and Vue to Netlify.
Both Django and Vue seem to be working great individually but when calling Django from Vue, I am having CORS issues (Blocked loading mixed active content “ip.address/authenticate/”)
The frontend is at https://address.work/
The backend is at http-ip.address (had to format this way because as a new user I can only post two links)
I suspect the CORS issues stem from the backend not being on SSL/https while the frontend is secured since I wasnt seeing them when both were on just http.
I tried to secure the backend but it seems like certbot/lets encrypt wont work on an IP address so I need a domain for the backend. At this point this feels like quite a bit of work just to be able to leverage Netlify.
2) Serving Django and Vue from the same Linode/DigitalOcean server.
This one seemed simple enough but I cant seem to figure out how to write the Nginx config for this. I am hopeful that someone on here can point me to the write direction since it seems like quite a few people use the JS+DRF stack.
In this case, I’d ideally have the frontend at address.work and the backend at address.work/api.
I currently have the following for serving just Django from the box.
server {
listen 80;
server_name 96.126.97.44;
location = /favicon.ico { access_log off; log_not_found off; }
location /staticfiles/ {
root /home/development/address/django/address_app/address_app;
}
location / {
include proxy_params;
proxy_pass http://unix:/run/gunicorn.sock;
}
}
In order to integrate Vue, my guesses are that I’d
-
Pointing Nginx to Vue using something like this:
location / {
root /home/username/yourproject/frontend/dist;
} -
Serving the API at /api
location /api {
include proxy_params;
proxy_pass http://unix:/run/gunicorn.sock;
}
I wasn’t use what pitfalls I’d be missing using this/if this is worth pursuing over the previous method but if someone has an Nginx file that addresses this, it would be super!