In this episode, we revisit a potential security issue where our app was exposing the full file path of uploaded files to the client. This isn't ideal—it basically lets clients see our server's directory structure, which could be risky!
We walk through exactly what's happening by logging what the client receives, showing how the real file path info is making its way to the browser. From there, we talk about what can be improved and decide to change the way we handle this. Instead of sending the full real path, we switch to just sending the file name. Since all the file chunks end up in the same directory on the server, the file name alone is all we really need to work with on the client side.
However, this means we also need to adjust how we piece together files on the server. Specifically, when reconstructing the file, we use a helper to build the correct path from the file name, pointing to the right directory.
By the end of the episode, we test it out to confirm everything still works, and now the client only receives the temporary file name—no sensitive paths exposed! Much better. We'll tackle a small error next time, but our file uploads are definitely more secure now.