0

It's simple set up.

Three docker containers in same network.

  1. ReactJs - production build on nginx server
  2. Spring Boot
  3. Mysql

GET, POST request works like a charm but when i try to use PATCH request i ends up with

Invalid CORS request

2021/09/01 23:17:27 [notice] 31#31: *5 "/api/(.*)" matches "/api/task/assign/5/S01", client: 172.18.0.1, server: localhost, request: "PATCH /api/task/assign/5/S01 HTTP/1.1", host: "localhost", referrer: "http://localhost/operator/controlpanel"
2021/09/01 23:17:27 [notice] 31#31: *5 rewritten data: "/task/assign/5/S01", args: "", client: 172.18.0.1, server: localhost, request: "PATCH /api/task/assign/5/S01 HTTP/1.1", host: "localhost", referrer: "http://localhost/operator/controlpanel"
172.18.0.1 - - [01/Sep/2021:23:17:27 +0000] "PATCH /api/task/assign/5/S01 HTTP/1.1" 403 31 "http://localhost/operator/controlpanel" "Mozilla/5.0 (Windows NT xx; Win64; x64; rv:xx) Gecko/20100101 Firefox/91.0" "-"

My nginx configuration

server {
  listen          80;
  server_name     localhost;
  expires -1;
  etag off;
  proxy_no_cache 1;
  rewrite_log on;

 location / {
   root /usr/share/nginx/html;
   try_files $uri /index.html;
 }

  location /api {
        rewrite /api/(.*) /$1  break;
        proxy_pass http://app:8080;
        proxy_pass_request_headers on;
        default_type  application/json;
  }
}

On spring boot end i do not received any request info so i assume it has been blocked before sending it to spring server.

Any idea what i'm doing wrong?

6
  • Check your application's log. Commented Sep 2, 2021 at 15:48
  • @MichaelHampton Like i mentioned "On spring boot end i do not received any request info so i assume it has been blocked before sending it to spring server." Plus PATCH, PUT, DELETE works fine without nginx
    – Lucas
    Commented Sep 2, 2021 at 16:05
  • Your app sent a 403 Forbidden error, so it must be doing something. Make sure your app is actually logging. Commented Sep 2, 2021 at 16:13
  • @Lucas, Encountering the same error here, did you ever find a solution? We can access the site without the proxy with no problems. As soon as the proxy is introduced, PATCH method results in 403 with a response of "Invalid CORS Request"
    – Slicktrick
    Commented Nov 16, 2022 at 15:45
  • @Slicktrick afair Michael was 100% correct spring didn't log that denial of access. Try to debug it before cors check.
    – Lucas
    Commented Nov 17, 2022 at 16:27

1 Answer 1

0

Your app sent a 403 Forbidden error, so it must be doing something. Make sure your app is actually logging. –  Michael Hampton Sep 2, 2021 at 16:13

For some reason spring didn't put that in logs. If someone face same problem try to debug request before cors filter.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .