I am having trouble figuring out how to serve static files for my Flask web app through Nginx and Gunicorn. All documentation I have seen online points to adding some path to static folder alias when a client makes a request for static files. However, I am not sure what the full path should be since the app is hosted on Heroku. All requests to static files are returning 404 errors. I also noticed that the XHR request to a JSON file stored in the directory path /static/json/<file>.json is not returning a JSON object on success.
Project Hierarchy:
project/
|_ config/
   |_ gunicorn.conf.py
   |_ nginx.conf.erb
|_ flask_app/
   |_ __init__.py
   |_ static/
      |_ css/
      |_ js/
      |_ images/
      |_ json/
|_ Procfile
|_ run.py
project/config/gunicorn.conf.py:
def when_ready(server):
    open('/tmp/app-initialized', 'w').close()
bind = 'unix:///tmp/nginx.socket'
project/config/nginx.conf.erb:
daemon off;
#Heroku dynos have at least 4 cores.
worker_processes <%= ENV['NGINX_WORKERS'] || 4 %>;
events {
    use epoll;
    accept_mutex on;
    worker_connections <%= ENV['NGINX_WORKER_CONNECTIONS'] || 1024 %>;
}
http {
    server_tokens off;
    log_format l2met 'measure#nginx.service=$request_time request_id=$http_x_request_id';
    access_log <%= ENV['NGINX_ACCESS_LOG_PATH'] || 'logs/nginx/access.log' %> l2met;
    error_log <%= ENV['NGINX_ERROR_LOG_PATH'] || 'logs/nginx/error.log' %>;
    include mime.types;
    default_type application/octet-stream;
    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    #Must read the body in 5 seconds.
    client_body_timeout 5;
    upstream app_server {
        server unix:/tmp/nginx.socket fail_timeout=0;
    }
    server {
        listen <%= ENV["PORT"] %>;
        server_name _;
        keepalive_timeout 5;
        # Configure NGINX to deliver static content from the specified folder
      location /static {
        alias /static;
      }
        location / {
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Host $http_host;
            proxy_redirect off;
            proxy_pass http://app_server;
        }
    }
}
project/Procfile
web: bin/start-nginx gunicorn -c config/gunicorn.conf.py 'run:create_app()'
worker: python worker.py
clock: python clock.py
example.js
export function getData() {
  $.ajax({
    type: 'GET',
    url: '/static/json/data.json',
    async: false,
    success : function(data) {
      currentPageIndex = 0;
      numberOfPages = data.length; // Getting undefined error here on "data"
    }
  });
}
 
     
    