How Can I Prevent My Nuxt.js Client Side Code From Being Delivered? Similar To .htaccess
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?
Answer
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 Questions
- → Maximum call stack exceeded when instantiating class inside of a module
- → Browserify api: how to pass advanced option to script
- → Node.js Passing object from server.js to external modules?
- → gulp-rename makes copies, but does not replace
- → requiring RX.js in node.js
- → Remove an ObjectId from an array of objectId
- → Can not connect to Redis
- → React: How to publish page on server using React-starter-kit
- → Express - better pattern for passing data between middleware functions
- → Can't get plotly + node.js to stream data coming through POST requests
- → IsGenerator implementation
- → Async/Await not waiting
- → (Socket.io on nodejs) Updating div with mysql data stops without showing error