-3

is it possible in nodejs, with express to hide the source-code in my static html directory, without rewriting new end-points for each html page?

server code looks like this and my website is in the directory html

  app.use(express.static('html'));

Im looking for something similar to a PHP echo, that hides client-side source code

user1709076
  • 2,538
  • 9
  • 38
  • 59
  • To display an html page on the client machine, you must send the html to the client machine. By doing so, you are sending the html to the client machine, so they can read it. The only way for the client to not see it would be for you to not send the html to the client at all, but at that point what good is the html? – Kevin B Mar 22 '17 at 15:55
  • im looking for something similar to PHPs 'echo' which hides html client-side since its rendered server side – user1709076 Mar 22 '17 at 15:57
  • no... that just sends text/html/whatever to the client.. – Kevin B Mar 22 '17 at 15:57
  • php and node.js operate very differently. with php, pages/routes are created by creating .php files, and you browse to that file via the browser to have it executed, thus returning the result. With node.js, you instead create an http server that interprets the path passed, and from that path it decides what content to return, whether it be a static file from a folder or a javascript function that writes text to the response object. – Kevin B Mar 22 '17 at 16:01
  • Exactly what "client side source code" do you want to hide here? Javascript code? – Gimby Mar 22 '17 at 16:18
  • I think what you want is something like ejs to perform some server side logic then render the page for the client. – Woodsy Mar 22 '17 at 18:22

1 Answers1

0

Does not look like nodejs is capable of performing a 'server side script' inside an html page, similar to

<?php
  //hidden script, source-code, leading up to an $echo
?>

such that the source-code of the script is hidden from the end-user if they were to 'view source'

user1709076
  • 2,538
  • 9
  • 38
  • 59