skip to Main Content

Why am I getting a 403 forbidden error only on put request API from CentOS 7 vps server (while get/post are working well)?

The same piece works fine on a shared hosting server and from localhost.

I am using “Nginx + Varnish + Apache”

Whenever I try to execute any PUT request, this is the response:

Forbidden
You don’t have permission to access /api/path/to/my/api on this server.

3

Answers


  1. You will have to use POST method along with _method= PUT as a form data:

                    let editUrl ="";                     
                     if (this.id) {
                            this.data._method = 'PUT';
                            this.data.id = this.id;
                            editUrl = editUrl + "/" + this.id;
                        }
    
                      axios.post(editUrl, this.data)
                        .then(resp => {
    
                        })
                        .catch(() => {
    
                        });
                }
    
    Login or Signup to reply.
  2. You have to explicitly permit PUT requests to your endpoint unlike GET and POST. You should look into your .htaccess settings.
    This question addresses the same concern and this also.

    Login or Signup to reply.
  3. Config your apache virtual host by these conditions:

    <Limit GET POST PUT OPTIONS>
        Require all granted
    </Limit>
    <LimitExcept GET POST PUT OPTIONS>
        Require all denied
    </LimitExcept>
    

    Maybe your problem solved.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search