I developed a web application that will make a post, and get & delete API calls.
All the above calls work perfectly fine in localhost.
But, the POST call fails when it is deployed to web servers, through the Nginx proxy. GET & DELETE works perfectly fine.
I observed, that in localhost, there are PREFLIGHT(options) & POST API calls. But while deployed through NGINX proxy.
There is no Preflight(options) call for POST methods, also 500 internal server error occurs.
Below is the success message of OPTIONS when it called through the local host, but this option call is missing when I deployed.
Here is the failure message for POST API in deployed web server, but the POST API is success in the localhost.
POST API success in localhost below
Here is the error logs from the instance
Here is the difference in headers localhost header (left) nginx (right)
Here is the nginx config location
location /api-hub/ {
proxy_pass http://****-***-***-dev-****.apps.cloud.a***cloud.local/api-hub/;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
limit_except GET PUT POST DELETE { deny all; }
override_charset on;
server_tokens off;
charset UTF-8;
source_charset UTF-8;
#add_header 'Content-Type' 'application/json; charset=UTF-8';
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
add_header Cache-Control "no-cache no-store private";
add_header Access-Control-Allow-Methods "GET, PUT, POST, OPTIONS";
add_header Access-Control-Allow-Headers "X-Custom-Software, X-My-Custom";
proxy_cookie_path / "/; SameSite=None; HTTPOnly; Secure";
proxy_hide_header X-Upstream;
#proxy_hide_header Content-Type;
expires $expires;
#add_header Access-Control-Allow-Origin "victsecst-25" always;
add_header Access-Control-Allow-Headers "X-Custom-Software, X-My-Custom";
keepalive_timeout 3600;
proxy_connect_timeout 300;
proxy_read_timeout 300;
proxy_send_timeout 300;
}




