0

I have build a WebApp which uses Vue and Retrieve Data using 'vue-resource' from Backend (Express + Postgres)

And I want to Improve it's security by Adding API Key.

I am bit confused is API Key is added as a variable on both the sides and if possible how to send it from vue-resource and get it on other end and authenticate?

3
  • I think this question is better to search online rather than to ask on here. Commented Jul 9, 2020 at 17:07
  • If you want better answers you need to be descriptive with your problem, and precise with what you need an answer to. Commented Jul 9, 2020 at 17:38
  • Question is now more descriptive 😊 Commented Jul 15, 2020 at 13:31

1 Answer 1

1

Create an API that talks to your Database, then the webapp talks to your API.

  • use JWT or Basic Auth between your app and this API
  • use the postgres credentials between the API and your database
  • create routes for the queries you'd like to run
    • /users/all = select * from users
    • /users/123 = select * from users where id = 123

This is a simple way to guarantee security.


Bonus points if you

  • dont use postgres as your credentials but create your own
  • only allow the IP of your API connection to your DB, and not a public IP.
  • use prepared statements to avoid accidental SQL injection and syntax mistakes
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks A lot. Actually I'm rookie but it helped me now I'm using JWT and tokens while logging in and I also enabled express-limitter.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.