I want to know how to make it so that users the visit my website can't see a javascript script file.
Let me elaborate:
Sometimes, in my Javascript, I have some config information for stuff like Firebase that I don't want others to see. If someone has that information, they could potentially take it and run it on their localhost and mess with my data. I need to have the private config information on my websites Javascript, or else the site won't work. But if others see that script, then they can copy it and use it on their site, which will mess up everything. I want to know how to make a private script.
If that's not possible, that's fine. I just want to know what I should do then.
Here are some things I have tried:
<!DOCTYPE html>
<html>
<head>
<script>
// config information
</script>
</head>
<body></body>
</html>
But that doesn't work. With Inspect Element, a user can easily find it.
Another idea was this:
<script src="js/config.js"></script>
But that doesn't help either, user can just inspect element, then right click on the link and say "Reveal Script in Source Panel"
What should I do?
If it's not possible to make the script private, just tell me. I just want to know what I should do.
index.htmlwith an ExpressJS app and expose an endpoint such as/configor/authenticateand do the authentication on the server side, then return the result as JSON. Then, on the client side, you can use the result without having exposes configuration details.