Express + EJS Templating

Hello, all. I am trying to deploy a site using Express and EJS templating. I am having slight trouble getting Express to render the routes appropriately. It works as expected both when I run the server using node and when I run it using netlify dev locally. My views are laid out as such:

/views/
– index.ejs
– template.ejs
– /auth/
---- signin.ejs
---- signup.ejs

I try to render these routes using res.render("auth/signin"). Netlify online gives me the error:

Error: Failed to lookup view in views directory “/var/task/views”

When I move the ejs files out of /auth/ and into /views/ it all works again, granted I updated my res.render() calls as well.

Why is Netlify online not finding the subdirectory in my views folder?

Here are some useful snippets:

server.js

app.set(“view engine”, “ejs”);
app.set(“views”, “views”);

netlify.toml

[functions]
external_node_modules = [“connect-mongo”, “body-parser”, “dotenv”, “ejs”, “express”, “express-ejs-layouts”, “express-session”, “mongoose”, “morgan”, “serverless-http”]
node_bundler = “esbuild”
included_files = [“page_views/", "dist/”]
[[redirects]]
force = true
from = “/*”
status = 200
to = “/.netlify/functions/server/:splat”

included_files = ["views/**", "dist/**"]
1 Like