Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

377
Visualizações
Apache HTTPD: PATCH request returns 404

I'm working on a web application that interacts with a custom REST API. It's basically a table of data that's updated through the application. I'm trying to use the PATCH method for the updates, but Apache is returning a 404 error when I send the request.

The weird thing is that a GET request to the same URL (i.e. pasting the URL into a separate browser window) works fine. Some details:

  • It appears that Apache is blocking the request before it gets to the custom REST API. I can see both PATCH and GET requests in the Apache access logs, but only the GET request appears in the custom REST API log (FWIW, the custom REST API is implemented in Flask) using Gunicorn as a hosting server.

    Example Apache access log records:

    192.168.0.1 - unknown [27/Aug/2021:18:23:27 +0000] "PATCH /admin-api/services/12872 HTTP/1.1" 404 14 "https://www.example.com/admin-dashboard/" ...

    192.168.0.1 - adminuser [27/Aug/2021:18:23:43 +0000] "GET /admin-api/services/12872 HTTP/1.1" 200 988 "-" ...

  • One thing I noticed is that the PATCH request is replacing the username with "unknown". This lead me to believe that something was wrong with CORS. I found a "Header" configuration that was missing OPTIONS and PATCH so I added them. Still seeing the same issue. Below is the current configuration of the option:

    Header always set Access-Control-Allow-Methods "POST, GET, OPTIONS, PATCH"
    
  • I'm not seeing a pre-flight OPTIONS requests in the Apache logs or browser console window. I've tried with Google Chrome (92.0) and Firefox (91.0).

  • The PATCH requests have the "access-control-allow-origin" header set to "POST, GET, OPTIONS, PATCH"

  • Apache proxy configuration uses a Unix socket to proxy to Gunicorn:

    <Location /admin-api>
      ProxyPass unix:/run/admin-api.sock|http://127.0.0.1
    </Location>
    
  • JavaScript fetch request: (apiUrl and id are variables set earlier in the function):

    let resp = await fetch(`${apiUrl}/services/${id}`, {
       credentials: "include",
       method: "PATCH",
       headers: {
         "Content-Type": "application/json",
         Accept: "application/json",
       },
       body: JSON.stringify({
         data: { min: 1, max: 3 },
       }),
     });
    
over 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda