How can an express api be used only for projects on the same server? (IP)

0

I have a project on a VPS server and in the same api running with Node and Express, it is accessible from outside and inside the server without problems, but I would like that this api could only be accessed by pages or app running on the same server.

Proble using app.listen (8080, 'localhost') ;, but nothing

    
asked by Mauricio Roa 22.06.2018 в 07:01
source

1 answer

0

You can install the cors module with npm i --save cors then add the following middleware to express:

app.use('*', cors({origin: <ruta de acceso>}))
    
answered by 23.06.2018 в 00:35