0

I am creating a middleware at my server end to modify the API calls in the following manner

http://example.com/xyz?jdvnjvjnfjAA536sddjjfjfjdjbdfjdh656dnjd5ndjvb

should be converted by the middleware to:

http://example.com/xyz?user=Tango&testID=123

where the earlier URL contains the encrypted string of the user=Tango&testID=123.

Hence simply put, the middleware decrypts the value and replaces it with the real string because i do not want to do decryption for over 50 API call view functions.

Is there any function available to modify the content occuring after "?" in django ?

Bakuriu
  • 98,325
  • 22
  • 197
  • 231
Shashwat
  • 172
  • 1
  • 10
  • Why don't you use HTTPS? Note that if the problem is to obtain a certificate be aware that you can obtain free valid certificates from [Let's Encrypt](https://letsencrypt.org/). By the way: when providing example urls that aren't meant to be clickable you should always use `example.com` which is hosted by IANA to be a *safe* target. Using anything else may take users to websites full of malware or phishing websites. – Bakuriu Aug 19 '16 at 10:45

1 Answers1

0

You can't modify the query-string from the server side. You basically have 2 options:

  1. issue a redirect response to tell the browser to request a different URL. See the Django docs on redirect.
  2. embed the new URL in your response along with javascript to rewrite the location using the HTML5 History API, see this SO question.
Community
  • 1
  • 1
Jody Boucher
  • 331
  • 1
  • 7