Skip to content
Snippets Groups Projects
Verified Commit d20601d2 authored by Jean-Baptiste Pasquier's avatar Jean-Baptiste Pasquier
Browse files

update: readme

parent d921f3da
No related branches found
No related tags found
No related merge requests found
Pipeline #1123 passed with stage
in 1 minute and 25 seconds
...@@ -267,9 +267,9 @@ INSTALLED_APPS = [ ...@@ -267,9 +267,9 @@ INSTALLED_APPS = [
] ]
``` ```
## 301 on domain mismatch ## 302 on domain mismatch
To enable 301 redirection on domain mismatch, add `djangoldp.middleware.AllowOnlySiteUrl` on `MIDDLEWARE` To enable 302 redirection on domain mismatch, add `djangoldp.middleware.AllowOnlySiteUrl` on `MIDDLEWARE`
This ensure that your clients will use `SITE_URL` and avoid mismatch betwen url & the id of a resource/container This ensure that your clients will use `SITE_URL` and avoid mismatch betwen url & the id of a resource/container
......
...@@ -8,8 +8,8 @@ class AllowOnlySiteUrl: ...@@ -8,8 +8,8 @@ class AllowOnlySiteUrl:
self.get_response = get_response self.get_response = get_response
def __call__(self, request): def __call__(self, request):
response = self.get_response(request)
if(is_safe_url(request.get_raw_uri(), allowed_hosts=settings.SITE_URL)): if(is_safe_url(request.get_raw_uri(), allowed_hosts=settings.SITE_URL)):
response = self.get_response(request)
return response return response
else: else:
return redirect('{}{}'.format(settings.SITE_URL, request.path)) return redirect('{}{}'.format(settings.SITE_URL, request.path))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment