cool-engine-68327
09/22/2022, 11:17 PMORY_SDK_URL
into our .env.local
file and it work correctly, into our OryCloud configuration we have set the custom ui like the image attached. It works fine, in local all work correctly, but in production, we’re receiving a lot of redirections and never can reach the UI directly into our app.
Is there something we should take into account to deploy an app to production?
PD.: We’re using a middleware to check if the session exist, if not, we redirect the user to the login flow. Again, in local it work expectedly…
// middleware.ts
function redirectToSignInFlow(request: NextRequest) {
return NextResponse.redirect(
new URL(`${edgeConfig.basePath}/self-service/login/browser`, request.url)
);
}
export async function middleware(request: NextRequest) {
try {
const headers = new Headers();
headers.set('Cookie', String(request.headers.get('cookie')));
const res = await checkSessionEdge(headers);
if (res.ok) {
return NextResponse.next();
}
return redirectToSignInFlow(request);
} catch (error) {
return redirectToSignInFlow(request);
}
}
cool-engine-68327
09/22/2022, 11:18 PMchekcSessionEdge
method is:
import { edgeConfig } from '@ory/integrations/next';
const checkSessionEdge = async (headers: Headers): Promise<Response> =>
await fetch(
`${process.env.NEXT_PUBLIC_VERCEL_URL}${edgeConfig.basePath}/sessions/whoami`,
{
headers,
}
);
export { checkSessionEdge };
magnificent-energy-493