M
M
Mikhail Ivanov2018-07-02 05:22:29
Node.js
Mikhail Ivanov, 2018-07-02 05:22:29

How to close rest api?

Good afternoon!
Tell me how to hide the public api, from public access, so that only my website (application on express.js) would have access to it. Is it possible to somehow sign it, or use third-party services?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Makarov, 2018-07-12
@MDiMaI666

token || secret key || OAuth2

A
Aleksei Podgaev, 2018-07-12
@alexiusp

you make it so that api should accept all requests only if there is a certain token in the header. if the token is missing or incorrect, you send back a response with status 401.
The client and server can receive this token, for example, through environment variables (so as not to shine them in the code)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question