nasa-gcn / gcn.nasa.gov

General Coordinates Network (GCN) web site
https://gcn.nasa.gov
Other
168 stars 41 forks source link

ACROSS API: Odd behavior when trailing slash added to API endpoint URLs #2091

Closed jak574 closed 3 months ago

jak574 commented 4 months ago

Bug Report Details :warning::bug:

Description

There's an odd behavior with ACROSS API endpoints, where if a trailing slash is added, it results in a 404.

For example, this URL: https://dev.gcn.nasa.gov/labs/api/v1/burstcube/too works fine and reports a JSON as expected, but the following URL with a trailing slash https://dev.gcn.nasa.gov/labs/api/v1/burstcube/too/ fails with a 404.

The 404 page URL does not match the input one (https://dev.gcn.nasa.gov/burstcube/too).

I tested the API code running under Uvicorn and the behavior is as expected, so I believe this is not an issue with FastAPI.

Steps to Reproduce

  1. Follow link https://dev.gcn.nasa.gov/labs/api/v1/burstcube/too/
  2. See 404 page
  3. Click this link: https://dev.gcn.nasa.gov/labs/api/v1/burstcube/too
  4. See that it reports a JSON as expected

Expected behavior: https://dev.gcn.nasa.gov/labs/api/v1/burstcube/too/ and links like this reports a JSON as expected

Actual behavior: Reports a 404.

lpsinger commented 4 months ago

Did you fix this in #2087?

jak574 commented 4 months ago

Did you fix this in #2087?

No, this behavior occurs post #2087. Prior to that change going to http://localhost:3333/labs/api/v1/burstcube/too resulted in a {"detail":"Method Not Allowed"} return, which was definitely not a good default behavior.

I would say here that not having the trailing slash is "more correct" for how an API URL like this should be. The reason I posted this issue is that the 404 when you add the slash only occurs when running inside the GCN environment, and if I run the API stand alone, it does not happen, which makes me think this is related to how the GCN code is handling the routes to /labs/api.