I'm having trouble uploading images using Cloudinary Adapter in Production (Heroku)
Steps to reproduce the behaviour. Please provide code snippets or a repository:
secureCookies: falseapp.set("trust proxy", 1);[Network error]: ServerParseError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
TypeError: e is undefined
In remote console
2020-01-17T14:03:17.474496+00:00 heroku[router]: at=error code=H13 desc="Connection closed without response" method=POST path="/admin/api" host=jumpittlabs-site-cms.herokuapp.com request_id=14e94647-88b8-43ef-9329-1aa1de849451 fwd="152.231.93.178" dyno=web.1 connect=1ms service=345ms status=503 bytes=0 protocol=https
I want upload image as it does in development
https://i.imgur.com/AyKyP7z.png
This is my index.js
require("dotenv").config();
const { Keystone } = require("@keystonejs/keystone");
const { PasswordAuthStrategy } = require("@keystonejs/auth-password");
const { GraphQLApp } = require("@keystonejs/app-graphql");
const { AdminUIApp } = require("@keystonejs/app-admin-ui");
const { MongooseAdapter: Adapter } = require("@keystonejs/adapter-mongoose");
const expressSession = require('express-session');
const MongoStoreMaker = require("connect-mongo");
const User = require("./models/User");
const Member = require("./models/Member");
const Project = require("./models/Project");
const Department = require("./models/Department");
const bodyParser = require("body-parser");
const { makeANiceEmail, transport } = require("./src/mail");
const MongoStore = MongoStoreMaker(expressSession);
const { ExpressApp } = require("@keystonejs-contrib/app-express");
const keystone = new Keystone({
name: "jumpittlabs-site-cms",
adapter: new Adapter(),
sessionStore: new MongoStore({
url: process.env.DATABASE_URL
}),
secureCookies: false
});
keystone.createList("User", User);
keystone.createList("Member", Member);
keystone.createList("Project", Project);
keystone.createList("Department", Department);
const authStrategy = keystone.createAuthStrategy({
type: PasswordAuthStrategy,
list: "User"
});
module.exports = {
keystone,
apps: [
new GraphQLApp(),
new AdminUIApp({ authStrategy }),
new ExpressApp(app => {
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
app.post("/email", async function (req, res) {
await transport.sendMail({
from: "'Mr. Fox 馃' <[email protected]>",
to: "[email protected]",
subject: "Hello World",
text: "Hello World?",
html: makeANiceEmail
}, (error, info) => {
if (error) {
return console.log(error);
}
console.log("Message sent: %s", info.messageId);
res.sendStatus(200);
});
});
})
],
configureExpress: app => {
if (process.env.NODE_ENV !== "development") {
app.set("trust proxy", 1);
}
}
};
Did you solve this? About to start testing heroku
Nope. I don鈥檛 know yet.
@alvaaz is there anything in the Heroku logs from the app itself? There should be some around the same time tagged as app[web.1] or similar.
I _suspect_ this is actually the same problem described in #2101.
Yep. I fix it for now, setting node version to 12.13.x in Heroku.
This fixed a similar issue for me. The error in the logs was the following:
EDIT: (This only happened while uploading images)
"name":"graphql"
"message": "Maximum call stack size exceeded"
...
"name":"GraphQLError"
"errors":[
{
"name":"RangeError",
"message":"Maximum call stack size exceeded",
"stack": "ReadStream.open (node_modules/fs-capacitor/lib/index.js:90:11)"
}
],
fixed by updating the engines on the package.json
{
"engines": {
"node": "12.16.x"
}
}
thanks @alvaaz