-
Hello, I have tried to set up the Ory Cloud Login on NodeJS with the following tutorial The setup with the Express.js app and the Ory CLI for the proxy works. I run the Ory Proxy with the following command:
And my index router is the following: var express = require("express")
var router = express.Router()
var sdk = require("@ory/client")
var ory = new sdk.V0alpha2Api(
new sdk.Configuration({
baseUrl: "/.ory",
}),
)
/* GET home page. */
router.get("/", function (req, res, next) {
ory
.toSession(undefined, req.header("cookie"))
.then(({ data: session }) => {
res.render("index", {
title: "Express",
// Our identity is stored in the session along with other useful information.
identity: session.identity,
})
})
.catch(() => {
// If logged out, send to login page
res.redirect("/.ory/ui/login")
})
})
module.exports = router Do I have to do something else so that the redirect back after the login is working. I have followed the tutorial but the result is not the same? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 9 replies
-
Sorry to hear that you're having trouble. Which version of the Ory CLI do you have? |
Beta Was this translation helpful? Give feedback.
Thank you - that was very helpful! I was able to reproduce the issue and pin point why it happened. In the end, you needed to set the correct SDK URL in the SDK config. This is currently incorrectly documented in our docs (I have fixed that). I have also pushed my changes to fix your project to your github repo :)
Thank you for your patience and sorry for the wonky experience here. We did not catch this error because we use the playground for testing, which is also the default SDK config, which is why we did not catch this bug.
ory/docs#952