aiji42 / prisma-data-proxy-alt

This is a library to alternate and self-host the Prisma Data Proxy (cloud.prisma.io)
MIT License
201 stars 28 forks source link

Recieved corrupt message when running locally #25

Closed jeremyjacob closed 1 year ago

jeremyjacob commented 1 year ago

Hi, thank you for your work on this project, it's been a real help using Prisma with Deno.

However, when trying to use the proxy I get an error:

Cannot fetch data from service:
error sending request for url (https://localhost:3851/4.7.1/b7b4fb7095922bd7b7c1126f4ffb522c4a94a7c7baa9310b74ef3789231d8756/graphql): error trying to connect: received corrupt message
    at wn.handleRequestError (file:///.../backend/generated/client/runtime/edge-esm.js:80:18717)
    at wn.handleAndLogRequestError (file:///.../backend/generated/client/runtime/edge-esm.js:80:18249)
    at wn.request (file:///.../generated/client/runtime/edge-esm.js:80:18087)
    at async t._request (file:///.../backend/generated/client/runtime/edge-esm.js:97:2022)
    at async file:///.../backend/src/prisma.ts:27:15
Watcher Process finished. Restarting on file change...

First thing I noticed was that it was trying to use https://. Is this perhaps the issue?

I put a console.log in the beforeMiddleware.js to log every request. Requests sent manually via curl to the proxy-alt server log to the console, but when using the Prisma client nothing gets logged, possibly indicating it never actually reached the server. I have a feeling it's expecting an https response and getting an http one, or something along those lines.

I'd like to run the proxy on localhost for integration tests :)

aiji42 commented 1 year ago

See https://github.com/aiji42/prisma-data-proxy-alt#launch-proxy-server

This will bring up the proxy server, but it must be SSL-enabled to connect from @prisma/client. So here are the steps to establish a local connection with SSL using docker-compose and https-portal with a self certificate.

@prisma/client communicates over https when in data proxy mode, even if local.

konuch commented 1 year ago

@jeremyjacob Hello, please, did you manage to run this on deno deploy by any chance?

jeremyjacob commented 1 year ago

At the time I was running this locally—not on Deno Deploy.