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

116
Visualizações
Sending HTTP request from mobile phone does not work like desktop (sending 'OPTIONS' instead of 'POST)

I have a dashboard that works by sending APIs to other parts of my server. It's a simple html form that is processed with JavaScript to send a fetch request, and the sent request is handled by my flask backend to do the task with the provided data.

The issue is that when the request is sent on desktop, it works properly. When I am sending it in iPhone using google chrome, the request is not sent properly. Instead of a 'POST' request, it is sending an 'OPTIONS' request.

Server logs show: "OPTIONS /api/message HTTP/1.1" vs desktop version of "POST /api/message HTTP/1.1"

Here is the JavaScript code:

  const options = {
      method: 'POST',
      headers: {
        'Accept': 'application/json',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify( params )  
  };
  fetch('https://myUrl.com/api/message', options )
      .then( response => response.text() )
        .then(response => {
          if (response == 'SUCCESS') {
            console.log(response)
            sessionStorage.setItem("success", "true"); 
            window.location.reload()
          } else {
            sessionStorage.setItem("error", response)
            window.location.reload()
          }
      })
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

My guess is that the browser sends a preflight request.

Different behaviour on desktop & phone might be explained by some phone-only optimizations implemented by browser's vendor.

about 4 years ago · Juan Pablo Isaza Relatório

0

It is sending a preflight request. I believe this is because I was using the HTTP instead of HTTPS and the request sends to HTTPS.

about 4 years ago · Juan Pablo Isaza Relatório
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