E
E
Eugene2018-11-10 16:56:23
Nginx
Eugene, 2018-11-10 16:56:23

How to implement DELETE method in nodejs behind nginx?

Good afternoon,
I am writing a service for storing pictures, and now I have problems with deleting.
All incoming requests are received by nginx, which redirects everything except static to nodejs. The nginx config looks like this:

location / {
        proxy_pass http://images/;
...
}
location /images/ {
        location ~* ^.+\.(jpg|jpeg|gif|png|svg)$ {
                try_files $uri $uri/;
        }
    }

The problem arises in using the DELETE method from nodejs, since `hXXps://myservice/images/path/to/image.jpg` is handled by NGINX.
How to implement correctly?
Maybe in the POST method, in the request body, pass something like action:upload or action:delete, depending on the desired action. Would this option be correct?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Arman, 2018-11-10
@fross

Can you check somehow

location ~* ^/images/.+\.(jpg|jpeg|gif|png|svg)$ {
  if ($request_method !~ ^(GET|HEAD)$) {
     proxy_pass http://images/;
  }

  if ($request_method ~ ^(GET|HEAD)$) {
     try_files $uri $uri/;
  }
}

up: the author of the question wrote the solution in the comments

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question