Trouble setting up Express routes within Netlify function

I’m trying to use a Netlify function with Express to setup a few routes that perform different tasks. I have a frontend preact app in the same project.

I could probably accomplish what I need just using separate netlify functions, but I’d much prefer to use Express for this project.

Here’s my function called my-hook.js

import express, { Router } from "express";
import serverless from "serverless-http";

const api = express();

const router = Router();
router.get("/test", (req, res) => res.send(JSON.stringify({ message: "Test finally works!" })));

api.use("/api/", router);

export const handler = serverless(api);

Here’s the toml file

[build]
  base = "frontend"
  command = "npm run build"
  publish = "/build"

[functions]
  directory = "functions"

[[redirects]]
  from = "/api/*"
  to = "/.netlify/functions/:splat"
  status = 200

This is a simplified version of the code I used for testing. When I try to reach this endpoint using postman, I get this error:

https://spraywell-suite.netlify.app/api/test

Cannot GET /api/test

I’ve tried many different variations of the URL and routing all to no avail.

However, I have a test route that doesn’t use Express which I can reach no problem.

Any help or insights would be greatly appreciated.

The site seems to be deleted.

I updated the URL. However… I just realized my coworker updated the code in the repo trying to get this to work (still to no avail).

I may need to create a public repo for this and repost this question. My apologies. However, if you see anything obviously wrong it would be appreciated. We just can’t seem to reach these simple endpoints…

Potential duplicate: Can't reach function endpoint using Express and Netlify functions - Cannot GET /api/badFunc/fulfilled