CodeForPhilly / CodeForPhilly/balancer-main

Standardize endpoint url format on trailing slashes

Open
#148 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
21
Forks
19
PR merge metrics
No merged PRs in 30d

Description

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](https://docs.djangoproject.com/en/dev/ref/settings/#append-slash), 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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.