admin管理员组文章数量:1303427
I have protected route component with redirection to authorization via keycloak service. On local i work with vite and proxy to api server.
I have auth endpoint from backend: http://localhost:3000/api/v3/auth/request?development_mode=1&redirect_to='http://localhost:3000/'
When i use this endpoint, its redirected me to keycloak service and after successfully authorization should return me back.
link from keycloak: ;response_type=code&redirect_uri=http://localhost:3000/api/v3/auth/callback&scope=email&state=%7B%27development_mode%27:%201,%20%27redirect_to%27:%20%27;nonce=
But the main problem is in protocols. My localhost working on http, but kecloak return me to https://localhost:3000
And a have error - This site can’t provide a secure connection localhost sent an invalid response. ERR_SSL_PROTOCOL_ERROR
PS: i was trying to use https on local via 'vite-plugin-mkcert', but after running local server i get error: 'This page isn’t working localhost didn’t send any data. ERR_EMPTY_RESPONSE'
It's so messy for me and a can't fugure out when whose side is the problem frontend or backend
export const ProtectedRoute = ({ children }) => {
const [cookies] = useCookies(['access_token'])
const currentUrl = encodeURIComponent(window.location.href)
if (!cookies.access_token) {
window.location.href = `http://localhost:3000/api/v3/auth/request?redirect_to=${currentUrl}&development_mode=1`
}
return children }
I have protected route component with redirection to authorization via keycloak service. On local i work with vite and proxy to api server.
I have auth endpoint from backend: http://localhost:3000/api/v3/auth/request?development_mode=1&redirect_to='http://localhost:3000/'
When i use this endpoint, its redirected me to keycloak service and after successfully authorization should return me back.
link from keycloak: https://keycloak.biacorp.ru/realms/aps/protocol/openid-connect/auth?client_id=aps-back-dev&response_type=code&redirect_uri=http://localhost:3000/api/v3/auth/callback&scope=email&state=%7B%27development_mode%27:%201,%20%27redirect_to%27:%20%27http://aps-dev.biacorp.ru%27%7D&nonce=
But the main problem is in protocols. My localhost working on http, but kecloak return me to https://localhost:3000
And a have error - This site can’t provide a secure connection localhost sent an invalid response. ERR_SSL_PROTOCOL_ERROR
PS: i was trying to use https on local via 'vite-plugin-mkcert', but after running local server i get error: 'This page isn’t working localhost didn’t send any data. ERR_EMPTY_RESPONSE'
It's so messy for me and a can't fugure out when whose side is the problem frontend or backend
export const ProtectedRoute = ({ children }) => {
const [cookies] = useCookies(['access_token'])
const currentUrl = encodeURIComponent(window.location.href)
if (!cookies.access_token) {
window.location.href = `http://localhost:3000/api/v3/auth/request?redirect_to=${currentUrl}&development_mode=1`
}
return children }
Share
Improve this question
edited Feb 4 at 14:36
David Abramov
asked Feb 4 at 14:11
David AbramovDavid Abramov
537 bronze badges
1 Answer
Reset to default 0Problem solved by switch localhost on https
And one more important thing: if you using vite-plugin-mkcert you should add mkcert() to plugins at vite.config:
import mkcert from 'vite-plugin-mkcert'
export default defineConfig(() => {
return {
plugins:[mkcert()]
server: {
https:true,
}
本文标签: reactjsRedirect from keycloak to https instead of http on localhostStack Overflow
版权声明:本文标题:reactjs - Redirect from keycloak to https instead of http on localhost - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741760024a2396348.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论