It seems my entire database is visible in JSON at example.com/api. I want to hide this from public view.
I also want to enable reloading on Vue, when not in the root directory. E.g. reloading example.com/example results in a 404 error by default. Vue documentation says to add try_files {path} / to the Caddyfile, but this then breaks the api and the database.
So in short: I want to enable reloading Vue pages, and hide the example.com/api from public view.
4. Error messages and/or full log output:
5. What I already tried:
See part 3 – try_files {path} / allows for reloading Vue pages, but then the database doesn’t work – presumably because it’s trying to access example.com/api via axios but this ‘loads’ that page instead of accessing properly?
But I’m not sure what you mean by “hide /api from public view”, because it has to be publicly accessible for your frontend Vue code to make requests to it.
You need to make sure your API is authenticated, so that users who aren’t logged in cannot fetch any information they shouldn’t see.
Perfect, thank you very much @francislavoie. That’s solved the reloading problem.
Regarding the /api, I mean that if I go to example.com/api, my entire mongoDB database is displayed in JSON format. For example, the first line could be:
Yep, it’s running with Node.js. I’m quite confused really, I thought the reverse_proxy in Caddy was doing that, Node is on port 4000 which is what my Caddy setting is.