How to deploy Strapi backend to Heroku with Postgres addon? - heroku

I have been using the official Strapi tutorial on how to deploy strapi to heroku with postgres and after following all the instructions, my heroku app is showing an error. However when I check the build logs, there are no errors and they show the build successful message.
build logs
2020-08-17T15:48:19.744258+00:00 app[web.1]: npm ERR!
2020-08-17T15:48:19.744486+00:00 app[web.1]: npm ERR! Failed at the radio-darya-backend#0.1.0 start script.
2020-08-17T15:48:19.744753+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-08-17T15:48:19.756754+00:00 app[web.1]:
2020-08-17T15:48:19.757071+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-08-17T15:48:19.757252+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2020-08-17T15_48_19_747Z-debug.log
2020-08-17T15:48:19.825573+00:00 heroku[web.1]: Process exited with status 1
2020-08-17T15:48:19.869487+00:00 heroku[web.1]: State changed from starting to crashed
2020-08-17T15:48:32.221633+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=radio-darya-backend.herokuapp.com request_id=1bceee5d-4452-4b2a-9638-d5f242b4337c fwd="213.162.246.193" dyno= connect= service= status=503 bytes= protocol=https
2020-08-17T15:48:32.751425+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=radio-darya-backend.herokuapp.com request_id=95d4de1a-5f17-49e3-bed2-b459bce9259e fwd="213.162.246.193" dyno= connect= service= status=503 bytes= protocol=https
package.json dependencies
"devDependencies": {},
"dependencies": {
"knex": "<0.20.0",
"pg": "^8.3.0",
"sqlite3": "latest",
"strapi": "3.1.4",
"strapi-admin": "3.1.4",
"strapi-connector-bookshelf": "3.1.4",
"strapi-plugin-content-manager": "3.1.4",
"strapi-plugin-content-type-builder": "3.1.4",
"strapi-plugin-email": "3.1.4",
"strapi-plugin-upload": "3.1.4",
"strapi-plugin-users-permissions": "3.1.4",
"strapi-utils": "3.1.4"
},
config database.js
module.exports = ({ env }) => ({
defaultConnection: 'default',
connections: {
default: {
connector: 'bookshelf',
settings: {
"client":"postgres",
"host":"${process.env.DATABASE_HOST}",
"port": "${process.env.DATABASE_PORT}",
"database": "${process.env.DATABASE_NAME}",
"username": "${process.env.DATABASE_USERNAME}",
"password": "${process.env.DATABASE_PASSWORD}",
"ssl": { "rejectUnauthorized": false }
},
options: {
},
},
},
});
her

This is working for me for v3.x strapi.
// Path: ./config/env/production/database.js
const parse = require('pg-connection-string').parse;
const config = parse(process.env.DATABASE_URL);
module.exports = ({ env }) => ({
defaultConnection: 'default',
connections: {
default: {
connector: 'bookshelf',
settings: {
client: 'postgres',
host: config.host,
port: config.port,
database: config.database,
username: config.user,
password: config.password,
},
options: {
ssl: false,
},
},
},
});
We also need to set the NODE_ENV variable on Heroku to production to ensure this new database configuration file is used.
heroku config:set NODE_ENV=production
see https://strapi.io/documentation/v3.x/deployment/heroku.html
Note here is v3.x instead of beta version. Google "strapi heroku postgres" for the moment still give legacy beta version.

You didn’t give the error message you’re having?
I did deploy my strapi to heroku a few weeks ago and there was no problems.
You are sure you followed all the steps from strapi documentation?
Only thing I could think to go wrong is database connection.
First you have to install postgress addon in Heroku, then get the config-info and last add environment variables in Heroku (settings/config vars) and also modify strapi config-files to get the database information from environment variables.
Strapi documentation: https://strapi.io/documentation/3.0.0-beta.x/deployment/heroku.html.
EDIT:
Strapi documentation isn’t correct at the moment, database.json file and location has been changed. See:
strapi database.js / multiple database configs
https://www.youtube.com/watch?v=xNE0TrI5OKk

ive just completed that tutorial a day ago... and i also had problems for a complete beginner to strapi and postgres and heroku... heres my experience.
follow along here to get postgres and the database setup:
https://tute.io/install-configure-strapi-postgresql
then complete your setup with the missing pieces from here:
https://strapi.io/documentation/v3.x/deployment/heroku.html
basically:
have postgres installed locally on your system, create the db and user and grant permissions.
install strapi without the quickstart flag and use the details that was used above.
use the heroku cli to set the configs derived from the database_url configvar.
commit and push and all should be well.
EDIT:
In Heroku under the app in question:
click setting and scroll down to Environment variable and click Reveal Config Vars
Ensure that you have a DATABASE_URL config var
Ensure that your postgres specific config vars match up to the DATABASE_URL
eg. DATABASE_URL = postgres://ebitxebvixeeqd:dc59b16dedb3a1eef84d4999sb4baf#ec2-50-37-231-192.compute-2.amazonaws.com: 5432/d516fp1u21ph7b
It's read like so: postgres:// USERNAME : PASSWORD # HOST : PORT : DATABASE_NAME
Also in your ./config/server.js file make sure your host is 0.0.0.0
module.exports = ({ env }) => ({
host: env('HOST', '0.0.0.0'),
port: env.int('PORT', 1337),
admin: {
auth: {
secret: env('ADMIN_JWT_SECRET', '***********************'),
},
},
});
Also change your database.js config to be:
settings: {
client: 'postgres',
host: env('DATABASE_HOST', '127.0.0.1'),
port: env.int('DATABASE_PORT', 5432),
database: env('DATABASE_NAME', 'strapi'),
username: env('DATABASE_USERNAME', 'postgres'),
password: env('DATABASE_PASSWORD', ''),
ssl: env.bool('DATABASE_SSL', false),
},
options: {}
Theres no much to go on from your question or the logs, but the above is basically some common issues ive experienced.

copy this code directly in the config/database.js
module.exports = ({ env }) => ({
defaultConnection: 'default',
connections: {
default: {
connector: 'bookshelf',
settings: {
client:'postgres',
host:`${process.env.DATABASE_HOST}`,
port: `${process.env.DATABASE_PORT}`,
database: `${process.env.DATABASE_NAME}`,
username: `${process.env.DATABASE_USERNAME}`,
password: `${process.env.DATABASE_PASSWORD}`,
ssl: { "rejectUnauthorized": false }
},
options: {
},
},
},
});

Related

"Error: Unknown dialect undefined" when deploying Strapi 4.0 app to Heroku

I created a Strapi app using the latest version, the new 4.0 and I wanted to deploy it to Heroku. I did follow the Strapi documentation in order to do so, like explained in this page. Now I'm getting an error that I don't understand, I guess it has something to do with postgres. This is the error
2021-12-18T15:26:26.658380+00:00 app[web.1]: [2021-12-18 15:26:26.656] debug: ⛔️ Server wasn't able to start properly.
2021-12-18T15:26:26.659122+00:00 app[web.1]: [2021-12-18 15:26:26.658] error: Unknow dialect undefined
2021-12-18T15:26:26.659123+00:00 app[web.1]: Error: Unknow dialect undefined
2021-12-18T15:26:26.659123+00:00 app[web.1]: at getDialectClass (/app/node_modules/#strapi/database/lib/dialects/index.js:12:13)
2021-12-18T15:26:26.659123+00:00 app[web.1]: at getDialect (/app/node_modules/#strapi/database/lib/dialects/index.js:19:23)
2021-12-18T15:26:26.659124+00:00 app[web.1]: at new Database (/app/node_modules/#strapi/database/lib/index.js:38:20)
2021-12-18T15:26:26.659124+00:00 app[web.1]: at Function.Database.init (/app/node_modules/#strapi/database/lib/index.js:84:33)
2021-12-18T15:26:26.659125+00:00 app[web.1]: at Strapi.bootstrap (/app/node_modules/#strapi/strapi/lib/Strapi.js:347:30)
2021-12-18T15:26:26.659125+00:00 app[web.1]: at Strapi.load (/app/node_modules/#strapi/strapi/lib/Strapi.js:410:16)
2021-12-18T15:26:26.659125+00:00 app[web.1]: at async Strapi.start (/app/node_modules/#strapi/strapi/lib/Strapi.js:161:9)
Apart from doing what is explained in the docs I linked, I just added a few collections using the UI in development mode. How can I fix this error and deploy to Heroku this new 4.0 version of Strapi?
I had a similar issue when I was connecting pg locally and then realised my connection config was incorrect. When I replaced it with v4 template it worked.
path: config/database.js
module.exports = ({ env }) => ({
defaultConnection: "default",
connection: {
client: "postgres",
connection: {
host: env("DATABASE_HOST", "localhost"),
port: env.int("DATABASE_PORT", 5432),
database: env("DATABASE_NAME", "bank"),
username: env("DATABASE_USERNAME", "postgres"),
password: env("DATABASE_PASSWORD", "0000"),
schema: env("DATABASE_SCHEMA", "public"),
},
}
});
And for Heorku as the article suggested:
path: config/env/production/database.js:
const parse = require('pg-connection-string').parse;
const config = parse(process.env.DATABASE_URL);
module.exports = ({ env }) => ({
connection: {
client: 'postgres',
connection: {
host: config.host,
port: config.port,
database: config.database,
user: config.user,
password: config.password,
ssl: {
rejectUnauthorized: false
},
},
debug: false,
},
});
PS: make sure you add pg-connection-string to your dependencies before pushing to heroku
getDialectClass - from the error log
const getDialectClass = client => {
switch (client) {
case 'postgres':
return require('./postgresql');
case 'mysql':
return require('./mysql');
case 'sqlite':
return require('./sqlite');
default:
throw new Error(`Unknow dialect ${client}`);
}
};
where the client is - db.config.connection
So if you have been following previous solutions - which talked about a connections object etc ( like this )
module.exports = ({ env }) => ({
defaultConnection: 'default',
connections: {
default: {
connector: 'bookshelf',
settings: {
client: 'postgres',
host: config.host,
port: config.port,
database: config.database,
username: config.user,
password: config.password,
ssl: {
rejectUnauthorized: false,
},
},
options: {
ssl: true,
},
},
},
});
db.config.connection would return undefined. & so it would fail
Configuring the DB with - https://docs.strapi.io/developer-docs/latest/setup-deployment-guides/configurations/required/databases.html#configuration-structure
Works fine
If you are using typescript in Strapi, we may encounter this issue too as there is a issue affecting Strapi typescript capabilities.
I can resolve the problem when I downgraded Strapi to 4.3.2 from 4.3.8
You can check this method using heroku/cli from strapi docs here, but it's the same thing, i'm using version 4.0.2, this methods works on older versions V3, i think the docs needs update, most of it is deprecated, for example "fetching only data (example: posts/project etc..) related to the authenticated user who created it", most of resources related to this topic in docs and forum are deprecated solutions that don't work in V4.
For the deployment, i have the same issue, i tried a lot of solutions but it didn't work for me to, but i managed to get the server running like this:
but i got this problem when i visit the "/admin" page:
Strapi is really interesting, let's hope they update the docs soon and someone respond with a solution here.
I fixed this issue by using database url directly. Not sure why the old way does not work in Strapi v4.
module.exports = ({ env }) => ({
defaultConnection: "default",
connection: {
client: "postgres",
connection: {
connectionString: process.env.DATABASE_URL,
ssl: {
rejectUnauthorized: false
}
},
}
});
In case someone meets the same problem as me.
In my situation, I am using vim in windows as my text editor. After editing the "config/database.js" file. It left a "database.js~" file in that directory. Then, this filename causes the same problems: "Error: Unknown dialect undefined".
I guess it's a bug in strapi. After removing that file, everything works!
So, the solutions for me. I add this line to my vim config file:
set backupdir=~/.vimbackup
Then create a directory named '.vimbackup' in "C:/User/[me]/" .
Strapi has once again changed the database configuration structure and even their deployment docs use the old and incorrect example.
Here is the most up to date example: Strapi Database Configuration
In strapi v4, you need to use like:
module.exports = ({ env }) => ({
connection: {
client: "postgres",
connection: {
host: env("DATABASE_HOST", "localhost"),
port: env.int("DATABASE_PORT", 5432),
database: env("DATABASE_NAME", "db-name"),
user: env("DATABASE_USERNAME", "postgres"),
password: env("DATABASE_PASSWORD", "password"),
schema: env("DATABASE_SCHEMA", "public"),
},
}
});
it's look like there is a problem in the new strapi version , when i try to create project with typescript support i faced same error , i don't know if you are using typescript in your project but these two solutions solved my problem;
solution (1) :- create compile config ts files with tsc $ tsc .\config\database.ts .\config\server.ts ./ .\config\admin.ts
solution (2) :- downgrade your strapi to 4.3.2 version in the package.json file.
solution (3) :- don't use #latest when creating strapi app instate use 4.3.2 npx create-strapi-app#4.3.2 test-strapi-verion-with-ts --ts
you can use one of theme

Heroku returns "Error: listen EADDRNOTAVAIL: address not available" on starting Strapi CMS

I am trying to deploy Strapi on Heroku
But it does not work. I get this log
2020-05-27T15:04:05.012958+00:00 app[web.1]: > strapi-oskogen-mongodb#0.1.0 start /app
2020-05-27T15:04:05.012959+00:00 app[web.1]: > node server.js
2020-05-27T15:04:05.012960+00:00 app[web.1]:
2020-05-27T15:04:08.188595+00:00 app[web.1]: (node:23) Warning: Accessing non-existent property 'count' of module exports inside circular dependency
2020-05-27T15:04:08.188639+00:00 app[web.1]: (Use `node --trace-warnings ...` to show where the warning was created)
2020-05-27T15:04:08.189164+00:00 app[web.1]: (node:23) Warning: Accessing non-existent property 'findOne' of module exports inside circular dependency
2020-05-27T15:04:08.189299+00:00 app[web.1]: (node:23) Warning: Accessing non-existent property 'remove' of module exports inside circular dependency
2020-05-27T15:04:08.189381+00:00 app[web.1]: (node:23) Warning: Accessing non-existent property 'updateOne' of module exports inside circular dependency
2020-05-27T15:04:12.308848+00:00 app[web.1]: [2020-05-27T15:04:12.308Z] error Error: listen EADDRNOTAVAIL: address not available 52.54.48.43:31639
2020-05-27T15:04:12.308857+00:00 app[web.1]: at Server.setupListenHandle [as _listen2] (net.js:1296:21)
2020-05-27T15:04:12.308858+00:00 app[web.1]: at listenInCluster (net.js:1361:12)
2020-05-27T15:04:12.308859+00:00 app[web.1]: at GetAddrInfoReqWrap.doListen [as callback] (net.js:1498:7)
2020-05-27T15:04:12.308859+00:00 app[web.1]: at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:68:8)
2020-05-27T15:04:22.927720+00:00 heroku[web.1]: Stopping all processes with SIGTERM
I use MongoDB on Atlas. It works well on localhost both dev and prod environment.
My production files:
server.js
database.js
response.js
app settings
Where did I miss something?
Which is the value of process.env.HOST. For some reason different from 0.0.0.0 (just a shot in the dark - https://strapi.io/documentation/3.0.0-beta.x/migration-guide/migration-guide-beta.19-to-beta.19.4.html#listened-host-changed)
I had to change server.js file (port 443):
module.exports = ({ env }) => ({
host: env('HOST', '0.0.0.0'),
port: env.int('PORT', 443),
admin: {
auth: {
secret: env('ADMIN_JWT_SECRET'),
},
},
});
My database.js file:
module.exports = ({ env }) => ({
defaultConnection: "default",
connections: {
default: {
connector: "mongoose",
settings: {
uri: env("DATABASE_URI"),
ssl: { rejectUnauthorized: false }
},
options: {
ssl: true,
authenticationDatabase: "",
useUnifiedTopology: true,
pool: {
min: 0,
max: 10,
idleTimeoutMillis: 30000,
createTimeoutMillis: 30000,
acquireTimeoutMillis: 30000
}
},
},
},
});
I hope it will help to somebody who has the same problem :-)
Not sure if it's what #Rochadsouza meant, but I got the same error and what finally solved the issue in my case was to set the host to 0.0.0.0. For some reasons, the host cannot be the app url, it needs to allow all hosts on Heroku. I was setting the host in server.js using env('HOST', '0.0.0.0') but had the HOST env var set to my app url on Heroku...
Hope it saves some time to others facing the same error.

Heroku Application Error - code=H10 desc="App crashed"

I am trying to deploy a dash app on heroku.
Everything works fine (also locally) except from when I run heroku open I get this Application Error:
heroku logs --tail then gives:
2019-11-22T22:55:41.598239+00:00 heroku[web.1]: State changed from up to crashed
2019-11-22T22:55:41.587218+00:00 heroku[web.1]: Process exited with status 3
2019-11-22T22:55:42.000000+00:00 app[api]: Build succeeded
2019-11-22T22:55:59.485489+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=romania2019.herokuapp.com request_id=d48fde4a-bd7e-47e2-9a21-bdf589ef281a fwd="152.115.83.242" dyno= connect= service= status=503 bytes= protocol=https
2019-11-22T22:55:59.851491+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=romania2019.herokuapp.com request_id=b6bbb5e8-8667-42f2-b083-b7bf26b5ae14 fwd="152.115.83.242" dyno= connect= service= status=503 bytes= protocol=https
Any suggestions where I should look next?
Here is my app.py I am trying to deploy:
import datetime
import time
import dash
import dash_core_components as dcc
import dash_html_components as html
import plotly
from dash.dependencies import Input, Output
import numpy as np
from selenium import webdriver
url = 'https://prezenta.bec.ro/prezidentiale24112019/abroad-precincts'
profile = webdriver.FirefoxProfile()
profile.set_preference("browser.preferences.instantApply",True)
profile.set_preference("browser.helperApps.neverAsk.saveToDisk",
"text/plain, application/octet-stream, application/binary, text/csv, application/csv, application/excel, text/comma-separated-values, text/xml, application/xml")
profile.set_preference("browser.helperApps.alwaysAsk.force",False)
profile.set_preference("browser.download.manager.showWhenStarting",False)
profile.set_preference("browser.download.folderList",1)
options = webdriver.FirefoxOptions()
options.headless = True
# create a new Firefox session
driver = webdriver.Firefox(firefox_profile=profile, options=options)
driver.implicitly_wait(30)
driver.get(url)
# Find button and click on it
ELEMENT = driver.find_element_by_xpath('//*[#id="root"]/main/section/div[1]/div[1]/div[5]/div/div[2]/div/h2')
def update(ELEMENT):
# time.sleep(2.9)
return int(ELEMENT.text.replace('.', ''))
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
server = app.server
app.layout = html.Div(
html.Div([
html.H4('ROMANIA - Presidential Elections Live Feed'),
html.Div(id='live-update-text'),
dcc.Graph(id='live-update-graph'),
dcc.Interval(
id='interval-component',
interval=60*1000, # in milliseconds
n_intervals=0
)
])
)
time.sleep(5)
#app.callback(Output('live-update-text', 'children'),
[Input('interval-component', 'n_intervals')])
def update_metrics(n):
no = update(ELEMENT)
style = {'padding': '5px', 'fontSize': '16px'}
return [
html.Span('Voters: {}'.format(no), style=style),
html.Span('Voters/Min: {}'.format(np.diff(data['number'])[-5:].mean()), style=style)
]
data = {'time': [], 'number': []}
# Multiple components can update everytime interval gets fired.
#app.callback(Output('live-update-graph', 'figure'),
[Input('interval-component', 'n_intervals')])
def update_graph_live(n):
# Collect some data
data['time'].append(datetime.datetime.now()) # + datetime.timedelta(seconds=3))
try:
no = update(ELEMENT)
data['number'].append(no)
except:
data['number'].append(no)
# Create the graph with subplots
fig = plotly.subplots.make_subplots(rows=2, cols=1, vertical_spacing=0.1)
fig['layout']['margin'] = {
'l': 30, 'r': 10, 'b': 30, 't': 10
}
fig['layout']['legend'] = {'x': 0, 'y': 1, 'xanchor': 'left'}
fig.append_trace({
'x': data['time'],
'y': data['number'],
'name': 'Voters',
'type': 'scatter'
}, 1, 1)
fig.append_trace({
'x': data['time'],
'y': np.diff(data['number']),
'text': data['time'],
'name': 'Voters / Min',
'type': 'scatter'
}, 2, 1)
fig.layout.update(height=800, )
return fig
if __name__ == '__main__':
app.run_server(debug=True)
It basically reads the number of voters and displays the number of votes per minute.
And the deployment instructions I've been following are given here: https://dash.plot.ly/deployment.
open your git bash and post
log --tails it will show your the error type H10 is app crasing due to some error missing dependencies or your procfiles is not well set so try reading the error types and look in your code. if your app is working fine in your local host try
web: gunicorn index:server --preload --timeout60.

Sending push from parse server hosted in heroku

I am following standard tutorial for using parse server in heroku from here.
https://github.com/ParsePlatform/parse-server/wiki/Push
I have used development .p12 file. My code in parse server is like this.
push: {
ios: {
pfx: 'mycert.p12', // The filename of private key and certificate in PFX or PKCS12 format from disk
bundleId: 'com.khantthulinn.example', // The bundle identifier associate with your app
production: false // Specifies which environment to connect to: Production (if true) or Sandbox
}
}
I use this curl to send push notification. App Id and master key is changed to fake one.
curl -X POST \
-H "X-Parse-Application-Id: QCsRSsKJTHs2YGi2BdBsLTLcf4U1JpQoRtTU9d0l
" \
-H "X-Parse-Master-Key: XoEVsXstyWl3M8sJK1qO0ll1G5bWJpTUmhX90du1
" \
-H "Content-Type: application/json" \
-d '{
"where": {
"deviceType": { "$in": [ "ios", "android" ] }
},
"data": {
"title": "Ant-man",
"alert": "This is awesome. It is awesome."
}
}' \
https://myexample.herokuapp.com/parse/push
In error logs, I have received like this.
2016-05-21T03:01:51.081259+00:00 app[web.1]: >
parse-server-example#1.4.0 start /app 2016-05-21T03:01:51.081265+00:00
app[web.1]: > node index.js 2016-05-21T03:01:51.081265+00:00
app[web.1]: 2016-05-21T03:01:52.581823+00:00 app[web.1]:
parse-server-example running on port 14168.
2016-05-21T03:01:52.698394+00:00 heroku[web.1]: State changed from
starting to up 2016-05-21T03:03:15.488214+00:00 heroku[router]:
at=error code=H13 desc="Connection closed without response"
method=POST path="/parse/push" host=myexample.herokuapp.com
request_id=0b5s4fbd-7258-4635-99a-178e37be15ce fwd="123.4.20.97"
dyno=web.1 connect=1ms service=11ms status=503 bytes=0
What do I need to set up in heroku?

invalid_credentials with omniauth on heroku

I implemented a project configured with OmniAuth/Twitter and OmniAuth/Facebook. in development mode with any problem.
But when i tried on heroku. it refused to work.
use Rack::Session::Cookie
use OmniAuth::Builder do
provider :twitter, ENV['TWITTER_APP_ID'], ENV['TWITTER_SECRET']
provider :facebook, ENV['FACEBOOK_APP_ID'], ENV['FACEBOOK_SECRET'], :scope => 'email'
end
Heroku logs
012-11-02T03:28:47+00:00 app[web.1]: E, [2012-11-02T03:28:47.339453 #58] ERROR -- omniauth: (twitter) Authentication failure! invalid_credentials: OAuth::Unauthorized, 401 Unauthorized
2012-11-02T03:28:47+00:00 heroku[router]: GET p####.herokuapp.com/auth/twitter/callback?oauth_token=r6l3GpwmxH38W8Q9WltcWs9PqyyGxxiGAUqXGFhmKs&oauth_verifier=O9HD6jLaEL1aRUcORIebGEZIQHbqtcgB012q5aZlCE dyno=web.1 queue=0 wait=0ms service=368ms status=302 bytes=9
2012-11-02T03:28:47+00:00 app[web.1]: 92.160.179.137 - - [02/Nov/2012 03:28:47] "GET /auth/failure?message=invalid_credentials&origin=https%3A%2F%2F p####.herokuapp.com%2Flogin&strategy=twitter HTTP/1.1" 200 3160 0.0033
2012-11-02T03:28:47+00:00 heroku[router]: GET p####.herokuapp.com/auth/failure?message=invalid_credentials&origin=https%3A%2F%2F p####.herokuapp.com%2Flogin&strategy=twitter dyno=web.1 queue=0 wait=0ms service=8ms status=200 bytes=3160
Thanks
A few things. Run $ heroku config and make sure the right keys are on Heroku.
Also, not sure about Twitter, but Facebook requires a callback url that you put in the settings for your app on developer.facebook.com, and that needs to point to the heroku url or it will be invalid.
Another long shot, but it could be an issue with CA certificates. I had that problem and fixed it with this in an initializer:
Rails.application.config.middleware.use OmniAuth::Builder do
provider :facebook, ENV['FACEBOOK_APP_ID'], ENV['FACEBOOK_SECRET'], {
client_options: { ssl: {
ca_file: '/usr/lib/ssl/certs/ca-certificates.crt',
ca_path: "/etc/ssl/certs"
}}
}
end
Hope this helps some..

Resources