Divu
Divu

Reputation: 19

Vuejs - How to Increase the security in Vuejs

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?

Upvotes: 0

Views: 754

Answers (1)

Kevin Potgieter
Kevin Potgieter

Reputation: 798

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

Upvotes: 1

Related Questions