Hi,
I have an issue about redirection.
Browser want to some page without session, I redirect it to login page. It's ok.
But I cannot make some ajax async request without session to redirect to the login page.
Here is my code using
Yichun Zhang's sample code about session.
access_by_lua '
local base32 = ngx.var.cookie_session
if base32 and base32 ~= "" then
local binary = ndk.set_var.set_decode_base32(base32)
local nickname = ndk.set_var.set_decrypt_session(binary)
if nickname and nickname ~= "" then
local uri = ngx.var.request_uri
local ret = ngx.location.capture("/some_location"..uri)
ngx.say(ret.body)
else
return ngx.redirect("../login/login.html", 301) --- Here is not working as I intend.
end
else
return ngx.redirect("../login/login.html", 301) -- Here is not working as I intend.
end
';
Browser only can receive the 'login.html' page text in the 'responseText' parameter at the callback function(defined by ajax call time)
And the status code 200 OK.
Is it possible to redirect internally or externally?
Thank you.