GitLab Pages 404 error from Fetch

I’m looking for some help fixing a 404 error on my GitLab Pages site. I don’t get this error when running locally, so I’m struggling to understand how to fix it once the code is built in my pipeline.

Background: on loading, my site attempts to fetch a number from collection in MongoDB to update the main page. I have an endpoint called /clicks on my server-side JavaScript (using Node.js), and on my client-side JS, I use the Fetch API to access that endpoint to get the number. Here’s the error I see in the Chrome dev tool:
fetch-404

The res.ok key is false, so the error is thrown.

Does this imply a problem accessing the server-side functions? Is this not available in GitLab Pages? Or does it imply that the MongoDB collection cannot be reached from this fetch method?

Thank you very much for any help.