prisma-examples: TypeError: Only absolute URLs are supported
Using the node-auth example on Ubuntu 18.04. When I start the project and try to query on my localhost playground, I get
Server is running on http://localhost:4000
TypeError: Only absolute URLs are supported
This is just a straight install from the example
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 20 (6 by maintainers)
Wild guess but are you using dotenv to set those environment variables? I was having the same problem and removing the ${env:PRISMA_ENDPOINT} variable that I had in the prisma.yml file solved my issue.
I would just like to add to this just in case someone else comes along with my same problem. I had
require('dotenv').config()
in my file along withconst { prisma } = require('./generated/prisma')
but I had them in the wrong order. You have to put the dotenv config BEFORE the prisma declaration.TL;DR Solution at the bottom
I have come across this problem while trying to set up multiple deployment environments for prisma (dev, staging and production).
### The problem
I used multiple env files to configure my prisma.yml file for deployment, my prisma.yml file looks something like this:
And thus, my generated prisma-client/index.js file had the endpoint as:
endpoint: `${process.env["PRISMA_ENDPOINT"]}`
The prisma client was fetching the environment variable PRISMA_ENDPOINT from the environment variables defined in the root folder rather than the environment variables defined in the prisma project folder.
### The solution
The solution was very basic and works after every deploy and prisma-client generation.
Add the prisma endpoint environment variable to your root .env file(s). Like so:
PRISMA_ENDPOINT = "https://my-example-prisma-server.com/service/default"
Hmm weird, can you please check in the generated
/src/generated/prisma-client/index.js
whether theendpoint
is set (should be in line 19).Also, can you confirm that
prisma generate
has been invoked successfully after the deploy? Could you please post the logs that you’re seeing after runningprisma deploy
.Finally, can you please try to run
prisma generate
manually and see if the issue still persists? Before runningprisma generate
, please ensure that the deploy was successful and that theendpoint
inprisma.yml
was set.