NodeJS Server on Raspberry Pi not calling function

by Ashley   Last Updated February 17, 2018 20:01 PM

I currently have a raspberry pi running Raspian OS which a Node JS server running on port 8080. I then setup NGINX to be used as a reverse proxy to route incoming port 80 traffic to my server at 8080.

I am trying to have the user click an HTML button which then calls a NodeJS function to redirect them to google. Now I don't think the problem lies in the code because if I run the server on my local computer (no nginx required) everything works fine. However when I try to access the server running on the Raspberry Pi from my local computer: works and serves the HTML page with the button but then the function call gives me a 404 error.

I believe I have something setup wrong in this reverse proxy, but I am VERY new to this so I have no idea what. Any help is appreciated.

NGINX default file

    listen 80;
    listen [::]:80;
    root /home/pi/Cortana;
    server_name _;
    location / {
        try_files $uri 4uri/ =404;


<form method="post" action="/Authenticate.js">
    <input type="submit" value="Login with Reddit" >


const http = require('http');
const request = require('request');
const fs = require('fs');
const express = require('express');

const app = express();
const server = http.createServer(app);

app.get('/', serveDefaultHTML);
app.get('/OAuthTest.html', serveAuthHTML);"/Authenticate.js", function(req, res){
    redirecting(req, res);

server.listen(8080, function(){
    console.log("Listening on http://localhost:8080");

function serveAuthHTML(req, res){
    fs.readFile("OAuthTest.html", function(err, data){
        if (err){
            res.writeHead(404, {'Content-Type': 'text/html'});
        res.writeHead(200, {'Content-Type': 'text/html'});

function serveDefaultHTML(req, res){
    res.writeHead(200, {'Content-Type': 'text/html'});
    res.write("Welcome to my server!")
    res.end("Request url: " + req.url);

function redirecting(req, res){
        {Location: ''}

Related Questions