On Saturday, September 12, 2015 at 2:11:31 AM UTC-7, Thomas Heller wrote:
> You are using an ajax request which does not follow the same rules as a
> normal browser navigation requests. It will not follow redirects for example.
>
> I don't know what ajax lib you are using but the general solution will be:
>
> fire request
> wait for response
> check response code of request
> if redirect get location header
> do cleanup of your local app
> then set document.location.href to location url
> the page will unload and load /login as "normal"
>
> or you could rewrite the server to not send a redirect but send the location
> encoded as data.
>
> HTH,
> /thomas
>
>
>
> >
> > The response to curl is as follows:
> >
> > HTTP/1.1 302 Found
> > Server: undertow
> > X-XSS-Protection: 1; mode=block
> > Location: http://localhost:3000/login <---------
> > X-Frame-Options: SAMEORIGIN
> > Date: Fri, 11 Sep 2015 21:06:28 GMT
> > Connection: keep-alive
> > X-Content-Type-Options: nosniff
> > Content-Type: text/html; charset=utf-8 <----------------
> > Content-Length: 0
> >
> > However, the reagent form is not getting redirected to he /login form. It
> > remains in the same form. On the console, I can see, however, the login
> > page is streamed as an HTML. ( I am using "/login" as just as an example.).
> >
> > The original reagent page is doing a request with CLJS-AJAX POST.
> >
> > Any hint is much appreciated. Thanks,
> >
> > Regards,
> > Hari
Hi Thomas,
Thanks for the answer. I still have one more issue related to this logic.
When I set the :location at the header onn the server side, what I see on the
client console (Chrome) is as follows (logging the response from the server):
I don't see the location key/value, instead, I see the whole page in HTML. Any
hint? tried with different doc-types.
{:status 200,
:success true,
:body "<!DOCTYPE html>\r\n<html>\r\n\r\n<head>\r\n <!-- Meta, title,
CSS, favicons, etc. -->\r\n <meta charset=\"utf-8\">\r\n
<title>----------</html>\r\n",
:headers {"date" "Sat, 12 Sep 2015 18:27:30 GMT", "x-content-type-options"
"nosniff", "server" "undertow", "x-frame-options" "SAMEORIGIN", "content-type"
"text/html; charset=utf-8", "connection" "keep-alive", "content-length" "3928",
"x-xss-protection" "1; mode=block"},
:trace-redirects ["/person" "/person"],
:error-code :no-error,
:error-text ""}
ON THE Client side, I solved the redirect issue with the following code:
(.assign js/location "/job")
But I couln't find the location in the header. So I hard-coded it here!
Thanks for the response.
Regards,
Hari
--
Note that posts from new members are moderated - please be patient with your
first post.
---
You received this message because you are subscribed to the Google Groups
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/clojurescript.