Home > Software engineering >  How can I prevent my Nuxt.js client side code from being delivered? Similar to .htaccess
How can I prevent my Nuxt.js client side code from being delivered? Similar to .htaccess

Time:02-16

I have a Nuxt.js app that is going into production with a domain. However the app is still under construction and nobody should see client-side delivered source code yet unless they have a specific access password.

.htaccess file is something that can be done for Apache servers but Nuxt.js is using a node backend server to deliver the client-side code right? So how can I configure that node server to prompt a login (classical html login alert prompt) before delivering any client-side code?

CodePudding user response:

Apache is a webserver, that have some configuration files it can read and execute accordingly. Node on the other hand uses express - http(s) server written directly for speed (faster than apache) and not using such things.

You have 2 ways of doing that i can think of fast

  • Use some other server and proxy(reverseproxy) the connections and lock the access on it (like apache proxying to nodejs).

Or a bit harder but i think better in performance and logic

  • You will need to write some global middleware, that would require some cookie value (if present, next(), otherwise show/handle login)
  • Related