Has anyone had success with using ory on a local d...
# ory-network
r
Has anyone had success with using ory on a local dev env without using the CLI? I don’t get why this is not part of the SDK and a separate application in the form of the CLI is required. This is super annoying when working in a team and also is annoying to deploy this (for test purposes). Even if I’d pay for the subscription the difference between the dev setup and production setup seem to be pretty annoying and I think there are better solutions
In my specific case I have a Go API that validates the authentication via a middleware, but given that it’s an API it doesn’t do the redirect. The API is consumed by a React SPA. Based on that it seems I’d need both the proxy and the tunnel kind of - e.g. if I want to retrieve session information from the React SPA
p
Hi @rough-ghost-22302 Thank you for the feedback. Is it difficult to use the Ory tunnel locally? What do you mean by
In my specific case I have a Go API that validates the authentication via a middleware, but given that it’s an API it doesn’t do the redirect.
The Ory tunnel should still work with
application/json
content-type and browser redirects. For testing environments such as staging, you could always add another domain to your project for easy deployment. Or just deploy the ory tunnel alongside your application.
r
A custom domain is not supported in the free dev tier (which I plan to use given that I’m just working on a POC for now), otherwise i would probably use some custom dns in a local resolv.conf for dev purposes which would make the whole dev env experience easier and more similar to a production environment
l
The NextJS integration has the tunnel built in to it. Not sure if that would be helpful for your PoC or not.
r
I don’t use NextJS, it’s a plain react spa that consumed an API that is implemented with Go
FWIW I tried to get it running with the Ory tunnel, but I’m not having any luck, kind of frustrating experience so far with the tunnel:
Copy code
ory tunnel --dev --project <http://peaceful-galois-l0mgoomxk2.projects.oryapis.com|peaceful-galois-l0mgoomxk2.projects.oryapis.com> <http://localhost:3000>
To access Ory's APIs, use URL

	<http://localhost:4000>

and configure your SDKs to point to it, for example in JavaScript:

	import { V0alpha2Api, Configuration } from '@ory/client'
	const ory = new V0alpha2Api(new Configuration({
	  basePath: '<http://localhost:4000>',
	  baseOptions: {
		withCredentials: true
	  }
	}))

2023/07/30 19:24:07 http: proxy error: remote error: tls: handshake failure
2023/07/30 19:24:08 http: proxy error: remote error: tls: handshake failure
2023/07/30 19:24:09 http: proxy error: remote error: tls: handshake failure
2023/07/30 19:24:18 http: proxy error: remote error: tls: handshake failure
2023/07/30 19:24:20 http: proxy error: remote error: tls: handshake failure
2023/07/30 19:24:28 http: proxy error: remote error: tls: handshake failure
To check if it works at all I visited
<http://localhost:4000>
and I see the TLS error in the browser as well as in the logs
Copy code
ory version
Version:    v0.2.2
Git Hash:   3ef9cd5f54d31fdc8da9ea3d9bfa1cfefb6f098d
Build Time: 2023-01-26T09:52:48Z
p
i think this is because you are visiting
<https://localhost:4000>
instead of
http://...
. Could you just make sure that the URL is a non-https url?
r
No I always use the http version:
Copy code
➜  ~ curl -I <http://localhost:4000>
HTTP/1.1 502 Bad Gateway
Strict-Transport-Security: max-age=0;
Vary: Origin
Date: Mon, 31 Jul 2023 09:22:11 GMT

➜  ~ curl -I <http://localhost:4000/self-service/login/browser>
HTTP/1.1 502 Bad Gateway
Strict-Transport-Security: max-age=0;
Vary: Origin
Date: Mon, 31 Jul 2023 09:22:39 GMT

➜  ~
for each issued 502 request it then shows the tls handshake failure msg too
p
Ah i see now, your
project
value is incorrect 😅 It should just be the slug. Not the full URL
Copy code
-- ory tunnel --dev --project <http://peaceful-galois-l0mgoomxk2.projects.oryapis.com|peaceful-galois-l0mgoomxk2.projects.oryapis.com> <http://localhost:3000>
++ ory tunnel --dev --project peaceful-galois-l0mgoomxk2 <http://localhost:3000>