Hey, it looks like a resource failed to load. If you have an ad-blocker, please turn it off.

Dark Mode Light Mode

Writing a Backend

Updated 15:05 on 1/4/2025

What's a Backend?

A backend is the part of a website you don't get to directly access; it handles requests that you make to any URL on the page. So, for instance, this page is titled "backend", and you access it through [url].org/backend. The server sees that and sends you this page.

It can also handle queries; say I wanted to build a "comments" feature, where anyone can leave a comment on any post I make. I can set up a request handler on a backend for a specific URL, say [url].org/comment?name={name}&body={body}, and it can handle that request, store it, and then attach it to my page so everyone else can see it!

What I Used

I previously used an Apache .htaccess file to control the way the site was presented; this had several disadvantages, namely:

  • I don't know Apache that well.
  • It was cumbersome to adjust, and it didn't really work for what I had in mind.
  • It wasn't set up to be a "true" backend; all I had was the .htaccess file, and the Apache documentation made my head spin.
  • I couldn't find a good way to set up a testing environment for it.

Given, a lot of that would have been minimized by things like.. "learning" "Apache", but who's got the time for that in this economy? So, I swapped to a node.js backend, and that's handling all my requests.

It honestly wasn't that hard to set up. Just get ChatGPT to write a basic template, optimize it, test it locally, then set it up on the web hosting service I use. Easy peasy.

What's next?

Honestly, I'm not sure. I think I need to rewrite the backend to serve up the CSS and other static content better, and then maybe work on a comment system? It probably isn't too hard. Probably. Then write more posts.

Thank you for reading.