404 header returned on existing route

Forgive me if this is touched upon later in the book (or in a chapter that hasn’t been included yet), I just started reading it about 10 minutes ago :slight_smile: Screenshot below of what I did.

By force of habit (with other projects), I generally use curl -I to verify my work in the terminal before opening a browser to verify things are working as they should. Expecting a 200 or even a 301, I instead got a 404. Figuring that I did something wrong, I scratched everything and started over again, only to once again get a 404 from the command line. Luckily, I then decided to verify the route in Chrome and received the expected Hello, world!

Is a 404 header expected behavior on a route, especially if only the headers are requested?

@falklian interesting! I would assume that making a HEAD request to a registered route should return a response. However, since you technically only register a GET request I can understand why. I would open an issue at GitHub - vapor/vapor: 💧 A server-side Swift HTTP web framework. for discussion! Sounds like either a bug in NIO or something that needs to be enabled (even on an opt-in basis)

Thanks for the reply!

I’ve gone ahead and submitted an issue on GitHub.

1 Like