Home > Software engineering >  API endpoints is working in localhost but not working with the URL
API endpoints is working in localhost but not working with the URL

Time:10-15

the API endpoints are working in localhost but at the moment I'm deploying it to the server, and some of the endpoints are not working.

http://localhost:xxxx/api/endpoint ==> working

https://myapiurl.com/api/endpoint ==> not working

Here is my Nginx configuration :

root /var/www/html;

        # Add index.php to the list if you are using PHP
        index index.html index.htm index.nginx-debian.html;

        server_name golivegameplan.com www.golivegameplan.com https://golivegameplan.com;

        location / {
                proxy_pass http://localhost:5000;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection 'upgrade';
                proxy_set_header Host $host;
                proxy_cache_bypass $http_upgrade;
                #try_files $uri $uri/ =404;
        }



    listen [::]:443 ssl ipv6only=on; # managed by Certbot
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/golivegameplan.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/golivegameplan.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot


}

Is there anything I'm missing?

CodePudding user response:

You might want to check if you're getting a CORS error. Is it functioning in postman?

CodePudding user response:

Have you tried using 0.0.0.0 in the proxy_pass directive instead of localhost?

  • Related