<@U04UQ68083H> How do I set a custom base UI URL w...
# ory-copilot
b
@chilly-king-10285 How do I set a custom base UI URL when using the tunnel for local development?
c
A message from kapa.ai
When developing locally, you can configure Ory to use UI views hosted on your local machine. To do this, you can use the Ory Tunnel to create a connection between your local environment and the Ory Network. This can be done by configuring the system to accept your local host URL as part of the same domain as your project. Here is an example of how you can set a custom base UI URL when using the tunnel for local development: 1. First, you need to have a running Ory Network project. You can create one with the following command:
Copy code
bash $ ory create project --name "Command Line Project"
2. Pass the project's slug as a flag to the tunnel command:
Copy code
bash $ ory tunnel --project <your-project-slug> <http://localhost:3000>
3. When developing locally, it is recommended to use the
--dev
flag, which uses a lax security setting:
Copy code
bash $ ory tunnel --dev --project <your-project-slug> <http://localhost:3000>
4. After starting the Tunnel, test it by performing the registration flow:
<http://localhost:4000/ui/registration>
. 5. Make sure to send any HTTP calls you make to
<http://localhost:4000>
and not
https://{your-slug}.<http://projects.oryapis.com|projects.oryapis.com>
. 6. When you configure the Ory SDK (here in Node.js), replace the
basePath
with your local host URL:
Copy code
javascript import { Configuration, FrontendApi } from "@ory/client"  const frontend = new FrontendApi(  new Configuration({    basePath: "<http://localhost:4000>",    baseOptions: {      withCredentials: true,    },  }), )  const { data: login } = await frontend.createBrowserLoginFlow() const { data: session } = await frontend.toSession() // ...
Remember, Ory Tunnel should be used for development purposes only. When you go to production, always add a custom domain to your project. For more information, you can refer to the [Ory documentation](https://www.ory.sh/docs/kratos/bring-your-own-ui/configure-ory-to-use-your-ui#development).
b
@chilly-king-10285 Yes, we're doing that: basePath is set as http://localhost:4000 (Ory tunnel), and we're using the project slug when starting Ory tunnel and using localhost:3000. Our issue is that after we authenticate with Google, we're directed to http://localhost:4000/auth?flow=46ff68e0-cf1b-4944-9af7-f2523ab03b4b when we SHOULD be directed to http://localhost:3000/auth?flow=46ff68e0-cf1b-4944-9af7-f2523ab03b4b
c
A message from kapa.ai
New message text here
b
@chilly-king-10285 How do I do this?
When developing locally, you can configure Ory Network to use UI views hosted on local machine, for example
<http://localhost:1234/login>
.
To do that, use Ory Tunnel to create a connection between your local environment and Ory Network and configure the system to accept
<http://localhost:1234/>
as part of the same domain as your project.
c
A message from kapa.ai
To configure Ory Network to use UI views hosted on your local machine, you need to use Ory Tunnel. Here's how you can do it: 1. First, you need to install Ory CLI if you haven't done so. You can find the installation guide [here](https://www.ory.sh/docs/guides/cli/installation). 2. Once you have Ory CLI installed, you can use the Ory Tunnel to create a connection between your local environment and Ory Network. Run the following command in your terminal:
Copy code
bash ory tunnel <http://localhost:1234> --project {project-slug} --dev
Replace
{project-slug}
with the slug of your Ory project. The
--dev
flag is used for development purposes and disables security checks for easier integration. 3. After running the command, your local environment is connected to the Ory Network and the system is configured to accept
<http://localhost:1234/>
as part of the same domain as your project. 4. Now, you can navigate to
<http://localhost:1234/login>
in your browser to access the UI views hosted on your local machine. Remember, Ory Tunnel should be used for development purposes only. When you go to production, always add a custom domain to your project. For more information, you can refer to the [Ory documentation](https://www.ory.sh/docs/guides/cli/proxy-and-tunnel).
b
@chilly-king-10285 Yes, that works, however when I get redirect back from Google authentication it still goes to the "tunnel" URL (http://localhost:4000 in our case) and not the UI URL (http://localhost:3000).
c
A message from kapa.ai
It seems like you're experiencing a common issue related to redirect URIs. When you're using social sign-in providers like Google, the redirect URI needs to be set correctly. If you're getting redirected back to the "tunnel" URL (`http://localhost:4000`) instead of the UI URL (`http://localhost:3000`), it's likely that the "Tenant URL"/`issuer_url` is not set correctly. You can check this in your Ory configuration. If you see an error like
Requested url does not match any rules
after clicking on "Sign in with Google", this is likely the issue. To fix this, you need to ensure that the "Tenant URL"/`issuer_url` is set to the correct UI URL (
<http://localhost:3000>
in your case). If you're still experiencing issues after checking this, it might be helpful to refer to the [Ory documentation on social sign-in troubleshooting](https://www.ory.sh/docs/troubleshooting/troubleshooting-social-sign-in).
b
@chilly-king-10285 How do I do this?
To fix this, you need to ensure that the "Tenant URL"/`issuer_url` is set to the correct UI URL (
<http://localhost:3000>
in your case).
c
A message from kapa.ai
To change the OAuth2 and OpenID Connect Issuer URL, you can use the Ory CLI command. Here's how you can do it: 1. Run the following command in your terminal:
Copy code
bash ory patch oauth2-config {project-id} --replace '/urls/self/issuer="<http://localhost:3000>"'
Replace
{project-id}
with the ID of your project. This command will change the issuer URL to
<http://localhost:3000>
. For more information, you can refer to the [Ory documentation](https://www.ory.sh/docs/oauth2-oidc/issuer-url).
b
c
A message from kapa.ai
It seems like the redirect URI is still pointing to the Ory Network domain (
<http://compassionate-cohen-n0elso3els.projects.oryapis.com|compassionate-cohen-n0elso3els.projects.oryapis.com>
) instead of your local environment (`http://localhost:3000`). To fix this, you need to update the redirect URL of the social sign-in provider (Google in your case) in the Ory Console. Here are the steps: 1. Open the Ory Console and navigate to the social sign-in configuration screen. 2. Choose Google and click on the configuration button. 3. Copy the Redirect URI from the form. 4. Replace the Ory Network URL (
<http://compassionate-cohen-n0elso3els.projects.oryapis.com|compassionate-cohen-n0elso3els.projects.oryapis.com>
) with your custom hostname, such as
localhost:3000
. 5. Update the Redirect URI - also called Authorization callback URL - in the Google OAuth client configuration. Make sure the Redirect URI matches the hostname you configured in the Ory Network configuration. For example, when your custom hostname is
<http://localhost:3000>
, the Redirect URI needs to be
<http://localhost:3000>
, not
<http://www.localhost:3000>
or
<http://localhost:3000/>
. Here is the command to update the `base_redirect_uri`:
Copy code
bash ory patch identity-config <project-id> --add '/selfservice/methods/oidc/config/base_redirect_uri="<http://localhost:3000>"'
Replace
<project-id>
with your project ID. For more information, you can refer to the [Ory documentation](https://www.ory.sh/docs/identities/sign-in/social-sign-in/redirect-url).
b
@chilly-king-10285 Unable to validate config: I[#/selfservice/methods/oidc] S[#/properties/selfservice/properties/methods/properties/oidc/additionalProperties] additionalProperties "base_redirect_url" not allowed
c
A message from kapa.ai
It seems like there's a typo in the command you're using. The correct property name is
base_redirect_uri
, not
base_redirect_url
. Here's the correct command:
Copy code
bash ory patch identity-config <project-id> --add '/selfservice/methods/oidc/config/base_redirect_uri="<http://localhost:3000>"'
Replace
<project-id>
with your project ID. This command will add the
base_redirect_uri
configuration to your project, setting it to
<http://localhost:3000>
. For more information, you can refer to the [Ory documentation](https://www.ory.sh/docs/identities/sign-in/social-sign-in/redirect-url).
b
@chilly-king-10285 Unable to validate config: I[#/selfservice/methods/oidc] S[#/properties/selfservice/properties/methods/properties/oidc/additionalProperties] additionalProperties "base_redirect_uri" not allowed
c
A message from kapa.ai
New message text here
h
I'm having a very similar issue. Trying to tunnel an Ory project locally. @billions-minister-2901 did you happen to resolve this somehow?
b
Unfortunately nope, still have an open issue.