I'm testing this on my linux localhost.
This is what I'm trying:
balter@spectre:/var/www/html$ cat .htaccess
Action cgi-node "/usr/bin/env node"
AddHandler cgi-node .js
balter@spectre:/var/www/html$ ls -al hello.js
-rwxr-xr-x 1 balter balter 99 Oct 31 13:17 hello.js
balter@spectre:/var/www/html$ cat hello.js
#!/usr/bin/env node
console.log("Content-Type: text/html");
console.log("hello from javascript");
balter@spectre:/var/www/html$ node hello.js
Content-Type: text/html
hello from javascript
When I visit localhost/hello.js
all I see is the contents of hello.js
ADDITION
I was wondering if I actually had cgi turned on. I figured I did because php worked. But I didn't have the cgi module enabled, or turned on in apache.conf
.
So I added cgi.load
and added to my apache.conf
###################################################################
######### Adding capaility to run CGI-scripts #################
ServerName localhost
ScriptAlias /cgi-bin/ /var/www/cgi-bin/
Options +ExecCGI
AddHandler cgi-script .cgi .pl .py .js
Now, I get
Forbidden
You don't have permission to access /hello.js on this server. Apache/2.4.18 (Ubuntu) Server at localhost Port 80
Incidentally, same with an equivalent hello.py
.