Having trouble to deploy on Heroku #1969
Replies: 1 comment 4 replies
-
I'm not sure why you were setting For your problems, I would have taken the following steps if I were in your shoes:
Note, PG host, port, user,password and name are just to make adonjs happy so that your app would build successfully because you wont't be connecting to your database with them. Hence, you can just fill them in with the same values you had in .env file during development. If you look closely on the environment variables on your heroku dashboard, you would see DATABASE_URL added automatically, that's what I normally use to connect to the postgres database. That should be all you need for env variables. Coming back to your applicationGo to the config folder, open database.ts file and replace the content with the code below: import Env from '@ioc:Adonis/Core/Env'
import { OrmConfig } from '@ioc:Adonis/Lucid/Orm'
import { DatabaseConfig } from '@ioc:Adonis/Lucid/Database'
import Application from '@ioc:Adonis/Core/Application';
const databaseConfig: DatabaseConfig & { orm: Partial<OrmConfig> } = {
connection: Env.get('DB_CONNECTION'),
connections: {
pg: {
client: 'pg',
connection: Application.inProduction ?
Env.get('DATABASE_URL') + "?ssl=no-verify":
{
host: Env.get('PG_HOST'),
port: Env.get('PG_PORT'),
user: Env.get('PG_USER'),
password: Env.get('PG_PASSWORD', ''),
database: Env.get('PG_DB_NAME'),
},
healthCheck: Application.inDev,
debug: Application.inDev,
},
/*
I usually use this custom connection to run database migrations on remote database from my local machine. For instance,
node ace migration:run --connection=custom, this will run the migration against you remote database. In order to use this connection, you must set DATABASE_URL in .env file, you can get the value from your heroku dashboard, or by running this command on your terminal: heroku config:get DATABASE_URL --app=your_app_name
*/
custom: {
client: "pg",
connection: Env.get("DATABASE_URL") + "?ssl=no-verify",
},
},
orm: {
},
}
export default databaseConfig These are usually my workflow when I work with heroku, you don't really have to follow them. But if you do, redeploy your app again |
Beta Was this translation helpful? Give feedback.
-
Hello guys, I'm trying to deploy my API Adonis JS 5.0 on Heroku.
I'm using Heroku Postgres for my database.
I already saw a discussion about the same error, but didn't solve for me.
In my package.json, my script "start" is that
ENV_SILENT=true node build/server.js
And my Procfile is that
release: ENV_SILENT=true node ace migration:run --force
web: ENV_SILENT=true npm start
To be honest, I already got 3 differents troubles.
The first one is
Error: AdonisJS requires "@adonisjs/assembler" in order to run typescript source directly
I already tried
npm install @adonisjs/assembler
and add"@adonisjs/assembler": "^3.0.6"
at the depedencies on the package.json, but still getting that error.The second one is a
Exception: E_MISSING_ENV_VALUE: Missing environment variable "HOST"
But I already put all values necessary (that I think) for a postgres pg, the enviroment variables is:
**DB_CONNECTION, PG_HOST, PG_PORT, PG_USER, PG_PASSWORD, PG_DB_NAME**
And the last error I got (now I dont have it, because when I tried to solve, I got back to the beggining)
When tried to get something to the route, I got
(query) 'table' doesn't exist
Well. I dont know where to find help about this.
If someone help me, I will be grateful :D
Beta Was this translation helpful? Give feedback.
All reactions