flagsmith icon indicating copy to clipboard operation
flagsmith copied to clipboard

API: Treat URLs with and without trailing slash as identical

Open luk355 opened this issue 4 years ago • 4 comments
trafficstars

Currently, any API calls without trailing / character returns default "Flagsmith API" response. This behavior is quite unusual in API world as its recommended to primarily accept API requests without trailing slash.

To quote a few articles:

A trailing forward slash (/) should not be included in URIs. This is one the most important rules to follow as the last character within a URI’s path, a forward slash (/) adds no semantic value and may cause confusion. REST API’s should not expect a trailing slash and should not include them in the links that they provide to clients.

As the last character within a URI’s path, a forward slash (/) adds no semantic value and may confuse. It’s better to drop it from the URI.

It would be great to treat requests with and without trailing slash as identical.

luk355 avatar Nov 15 '21 09:11 luk355

@dabeeeenster, I presume this would be simple change in django configuration which would save time to any developer using the Flagsmith API.

luk355 avatar Jun 29 '23 14:06 luk355

Hi @luk355 , I'd love it to be that simple but django's management of this has always been a little bit confusing, particularly its interaction with django rest framework's routers and viewsets. I'll take a look at it to see what we can do, but it's not as trivial as it sounds!

matthewelwell avatar Jun 29 '23 15:06 matthewelwell

Any updates on this? Currently trying to use a self managed flagsmith with apps within Kubernetes and in Kubernetes it's not working (possibly because the CNI is trying to sanitise the requests and thereby removing the trailing /). Since it's managed Kubernetes I'm unable to change CNI settings so we'd love the possibility of flagsmith working without a required trailing /

jobstoit avatar Nov 14 '23 10:11 jobstoit

@jobstoit we have a lot of installations running on k8s in a variety of different platforms so I'm surprised that this is causing an issue. Do you have more information about the issues you're facing? Perhaps you can raise them in our discord channel? Here's an invite: https://discord.gg/QydC8y8U

matthewelwell avatar Nov 14 '23 12:11 matthewelwell