Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standardize endpoint url format on trailing slashes #148

Open
snaeem3 opened this issue Jul 10, 2024 · 0 comments
Open

Standardize endpoint url format on trailing slashes #148

snaeem3 opened this issue Jul 10, 2024 · 0 comments

Comments

@snaeem3
Copy link
Collaborator

snaeem3 commented Jul 10, 2024

Currently if the front-end makes an API request to the backend, the url needs to be an exact match in order to get a response otherwise it returns a 500 TemplateDoesNotExist exception or a Forbidden (403) error.

I experienced this issue when creating a test endpoint with the url localhost:8000/endpoint and tried making requests to localhost:8000/endpoint/. Similarly, the same error happens when the endpoint url is localhost:8000/endpoint/ and a call to localhost:8000/endpoint is made.

  1. There should be a standard for whether we include a trailing slash or not in the django urls.py files. As an example server/api/views/jira/urls.py has no trailing slashes for any of the endpoints, server/api/views/listMeds/urls.py has trailing slashes, and server/api/views/chatgpt/urls.py has both trailing slashes and no trailing slashes in the urls
  2. There should be a way to automatically redirect a url with or without a trailing slash to the correct endpoint. According to the Django docs, this error shouldn't be present. I'm not entirely sure why it isn't working here.
  3. On the front end, it could be beneficial to create a apiClient.ts file that contains every axios api request and react components can import the necessary functions rather than write them internally. This would help with standardizing api requests from the front-end

I'm also unsure as to why for some incorrect url calls, it returns the 500 TemplateDoesNotExist exception vs. Forbidden (403) error. However the fix should address both of these.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant