So now at this point, we're pretty much done with this demo REST API.
Now, you could add more features, you could add global error handling, you could clean up the code,
you could add more features in general to this API, of course.
But I actually just want to do one additional thing here.
I want to make sure that we can really interact with that API from inside a front-end application.
And to do that, at least two important things are missing here.
Because whilst we could interact with the API with tools like Postman for testing it,
if we had a decoupled front-end web application or a mobile application,
we would most likely run into errors if we were to send requests to that API.
Because we must set appropriate headers on all the responses sent back by that API
to ensure that decoupled front-ends are really allowed to send requests.
We must set so-called coarse headers, we must enable cross-origin resource sharing.
Now, we could do that manually, also with help of the documentation here on MDN, for example.
But we can also just install a package that will set those headers for us,
the coarse package with npm install coarse.
And then, of course, we could ask AI to help us here, but we can also do it manually
or use a combination, start typing and let AI, GitHub Copilot, help us as we did it many times before.
And then also make sure to register this middleware,
which is what we need to do when building such a Node Express application.
This middleware here will ensure that the appropriate headers are set for all the responses
that are being set to possible front-ends that might want to reach out.
But that's not all.
In addition, I also want to make sure that any images that were uploaded here
can actually be requested from outside this application here as well,
so that requests can be sent to those images.
And for that, I want to statically serve them.
And we can again do that with help of some middleware.
So here, I'll start typing and I'll see if I get an appropriate suggestion.
No, that's not it.
But I know that I want the static middleware, so with some extra characters added,
this gets completed and this code will simply ensure that whatever is in this public folder
can directly be requested without us setting up a dedicated route in this application.
So that's something else we want to do here to make sure that these images can be visited.
With that, if I ensure that my development server is up and running
and I grab this image name here, including the extension,
I can open up the browser, enter localhost 3000,
and then slash images, slash the image name, and the image will be loaded.
And that's only possible due to this middleware being added.
If I were to remove it and save this, reloading would give us an error.
So that's all that's important here.