Cannot GET using Express

i get a live depoly, index.html page loads, but i cant get to any of the other HTML pages
directory structure is:
in the root directory:
WS server.js

websocket server seems to be working but i get an error of “404 cannot Get” on all subfolder HTML pages, the index.html in the root loads correctly

this is the code for the express static folders:
const app = express();

// Serve static files for client folder
app.use(‘/client’, express.static(path.join(__dirname, ‘public/client’)));

// Serve static files for control folder
app.use(‘/control’, express.static(path.join(__dirname, ‘public/control’)));

// Serve static files for CSS folder
app.use(‘/css’, express.static(path.join(__dirname, ‘public/css’)));

// Serve static files for index.html
app.use(express.static(path.join(__dirname, ‘server’)));

app.get(‘/’, (req, res) => {
res.sendFile(path.join(__dirname, ‘index.html’));

not sure why this is happening?


I’ve also replied to the couple of ticket you opened, I’ll add the same response here for completeness:

It sounds like you’re trying to run multiple separate servers on a Web Service. A Web Service can only have public HTTP requests to one process/port. So if you’re trying to run an Express server and separate Web Sockets server on the same Web Service, only one of the processes will be accepting requests from the URL, and from your description, it sounds like it’s the Web Sockets server.

You’ll either need to run them as separate Web Services or ensure all requests are going through a single web/http server.

Hope that helps


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.