Express routing to static pages doesn't route in Apps (Sub folders)

I’ve beaten my head all weekend trying to find this. I’m new to Digital Ocean apps but very versed in other parts of DO. I may be going about this wrong entirely, but I can say that the below works just fine on localhost and in a droplet. This seems related to apps. Understand that the app deploys just fine, and the port spins up with node. My issue is the express 'app.get. routing.

Specifically this:

app.get("/", (req, res) => {

when I hit the page in a browser with / it redirect to:

(Which is the correct path)

But I get the error: “Cannot GET /assets/index.html” in the browser. I can’t seem to manually traverse to any assets honestly beyond app.js which is in the root.

The structure of my folder structure (which I’m open to ideas) is:


  • assets
    • css
    • img
    • js
    • scss
    • vendor
    • index.html
  • app.js -package.json -package-lock.json

My Package.json is:

  "name": "Test",
  "version": "1.0.1",
  "description": "The Website with submit form",
  "main": "app/app.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "node app/app.js"
  "author": "ME",
  "license": "ISC",
  "dependencies": {
    "@sendgrid/mail": "^8.1.1",
    "body-parser": "^1.20.2",
    "cors": "^2.8.5",
    "dotenv": "^16.4.5",
    "express": "^4.18.3"


app.js is below. The HTML file really doesn’t matter. Its index.htmkl

const express = _require_('express');
const _bodyParser_ = _require_('body-parser');
const app = express();
const cors = _require_('cors');
const _sgMail_ = _require_('@sendgrid/mail');
//const path = require("path");
_console_.log(`Hello ${_process_.env.SENDGRID_API_KEY}`);

app.use(_bodyParser_._urlencoded_({extended: true}));
app.use('/assets', express._static_(_process_.cwd() + '/assets'));


app.get("/", (req, res) => {
})'/formHandler', (req, res) => {
    _console_.log('This the post function!!!! ', req.url);

    const msg = {
        to: `${_process_.env.SENDGRID_TO}`,
        from: `${_process_.env.SENDGRID_FROM}`,
        replyTo: `${}`,
        subject: `${req.body.subject}`,
        text: `${req.body.content}`,

    if ( === undefined && req.body.subject === undefined && req.body.text === undefined) {
        _console_.log('found bad packet');
    } else {
_            .send(msg)
            .then(() => {
                _console_.log('Email sent');
                res.json({success: true})
            .catch((error) => {
                res.json({success: false, error: 'Bad'});

const PORT = _process_.env.PORT || 8080;

app.listen(PORT, () => {
    _console_.log(`Server running on port ${PORT}`);

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Site Moderator
Site Moderator badge
March 14, 2024


If I get this correctly you are having issues serving the static files, correct?

Please give the following docs a read and see if that would help out:

Additionally, it’s weird to have your index file in the assets file, can you try putting it anywhere else just to see how it goes?

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel