nested routes using Mux Router getting 404, while singly nested routes work

whitallee
HOBBY

3 months ago

I'm working on a backend API service in Golang using Mux Router. On my localhost the endpoints work perfectly fine, but deployed, only the endpoints that are 1 level deep in the subrouter will work. /api/v1 is my subrouter path prefix.

Here are some examples:

/api/v1/species GET works perfectly fine deployed via github, hosted on railway and on my localhost

/api/v1/habitat GET works fine too on both environments

/api/v1/enclosure GET, POST, PUT, DELETE all work fine in both environments

/api/v1/user/login works fine on localhost but does not work on the railway hosted environment (404)

/api/v1/admin/species works on localhost but not on railway (404)

/api/v1/admin/habitat works on localhost but not on railway (404)

I've looked thru the logs and everything but cant seem to find any sort of clues as to whats happening. Not getting any descriptive errors or anything, just the 404 response. Let me know if you need more context to help. Below are the versions im using in my codebase.

Golang v1.23.4

Gorilla Mux v1.8.1

repo is https://github.com/whitallee/animal-family-backend if you want to take a look at the source

Thanks for any help at all!

Solved

2 Replies

whitallee
HOBBY

3 months ago

I feel really stupid. It turns out, after days of trying to figure this out, that I had simply forgotten the https:// when typing in my Postman environment variables. Feel free to close or delete this thread, thanks.


whitallee

I feel really stupid. It turns out, after days of trying to figure this out, that I had simply forgotten the https:// when typing in my Postman environment variables. Feel free to close or delete this thread, thanks.

3 months ago

I am glad that you have managed to solve this issue yourself, I'll go ahead and mark this thread as solved.


Status changed to Solved uxuz 3 months ago