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

267
Visualizações
Nodejs limit the API access to hosted web app

enter image description here

I have a hosted admin panel under the domain admin.foo.com and the API hosted under the domain api.foo.com

I have an open endpoint GET - api.foo.com/all-products. There is no authentication header required to access this resource. But this should be accessed only via the hosted web app.

The user should not be able to copy this url and paste on the web browser and see the json response and also user should not be able the data from this endpoint via another API or something.

This question is already asked in StackOverflow but the given answer is this is not possible due to powerful tools like postmon. But this should be able to achieve to at least for some extent using Node.js and express.js features.

Say check where the request is coming from and then block the resource something like that. How do I achieve this using Node.js, Express.js?

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

0

What you are looking for is cors

const cors = require('cors');
app.use(cors({
    origin: 'https://admin.foo.com'
}));

More info: https://www.section.io/engineering-education/how-to-use-cors-in-nodejs-with-express/

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