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

245
Visualizações
Make POST API Request Without Allowing Other People Access

I am trying to code a website where the user inputs information and it is passed to the backend (node.js/express.js) by the JavaScript. I don't want just anyone to be able to POST the JSON to the server, just the website's code. I am not sure how to do this as I can't use authorisation keys because that would be available as the code is client-side.

The server is using express.js run on node.js and the frontend is just JavaScript triggered from an HTML file.

Any help appreciated!

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Short answer: you can't.

Long answer:

Once your API is public on the Internet, everything can connect to it as long as it has network capabilities. Telnet, HTTP, Go program, Node.js scripts, Python scripts, etcetera.

You can limit your API access by using CORS policy, authorization header, user-agent header, referrer header, rate limiter and the like, but it's only a deterrent and everything can be spoofed by a malicious user.

In my opinion, you shouldn't worry about that, really. If you really really want security, and do not want others to access your API, consider implementing a user authentication system with JWT or sessions with secure cookies. It's the best way to protect your endpoints.

Check out these OWASP articles below to learn more about API security.

  • OWASP Top API
  • OWASP Safe REST

If you want to learn more about secure cookies and user authentication in Express, you can check the following articles:

  • Sending Cookies in Express
  • Express Session Management
  • Implementing Secure, HTTPOnly Cookies

I also have one more good article, it's in Go, but you can adapt the concepts in Express.js as well. Here's the link.

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