Reputation: 211
Our react application is working properly in our local machine. but we deplayed it into higher environement it is not working.
it sends 405 Method not allowed error
. pages are getting loaded. whenever we request submit form
this issue comes.
Below is my nginx.conf
file.
which parameter I am missing?
Upvotes: 4
Views: 14696
Reputation: 195
Based on your Nginx configuration, I see that it does not contain any configuration for processing POST requests. It means all your requests will be routed to static files, that by default is not allowed by Nginx. When Nginx gets a POST request to the static file content - it generates a 405 Not Allowed error.
If you are planning to process POST requests by your specific backend implementation, probably you are required to create an upstream server, where it will redirect your request.
You can do it based on my current configuration, where is 127.0.0.1:3030 IP address and port of your backend application:
upstream node_server {
server 127.0.0.1:3030;
keepalive 8;
}
server {
server_name example.com;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://node_server/;
proxy_redirect off;
}
}
Upvotes: 2