-
Notifications
You must be signed in to change notification settings - Fork 549
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
App error - Official staticman api on Heroku. #332
Comments
@IgorKowalczyk support has been dropped for the public instance. Please refer to the README for instructions on how to easily deploy your own instance to the free tier of heroku. Self hosting should provide you a much more reliable experience and the free tier of heroku is more than sufficient. I will be closing this issue but please feel free to post any further questions you may have here. |
I tried to put it on the Heroku, but unfortunately, no guidebook worked for me... |
I'm happy to assist you if you can tell me more about what went wrong when deploying your own to Heroku. Unfortunately it is not feasible for us to run a reliable public instance off of this community run project. |
Let me explain. I've been doing everything as it's been handed down here: https://vincenttam.gitlab.io/post/2018-09-16-staticman-powered-gitlab-pages/2/ and here: https://muffinman.io/running-staticman-on-heroku/ unfortunately I didn't get to the correction in the second article because I had problems in the first one. Sorry about my English too. (Translator - not google of course 😄) |
I would recommend consulting the README of this repo which has some more updated instructions. There is a "Deploy to Heroku" button in the README which simplifies much of the steps indicated in those links you provided. The discussion at the end of this issue may provide some additional clarity. |
Thank you, but I have a problem with the configuration file... From:
With the RSA key copied straight from the Github, change the text " |
If you are hosting on GitHub pages, then use the "githubToken" key and remove the "gitlabToken" key. If you are hosting on GitLab pages, then use the "gitlabToken" key and remove the "githubToken" key. The text for the "rsaPrivateKey" value should be changed to the text of your own private RSA key as a single-line string with |
I don't understand it... |
Have you created a public/private RSA key pair? If not, follow the steps outlined here to create one. Once you have a key pair generated, it'll likely be stored in
As you can see, here we have a multiline, key string. However, the configuration value must all be on one line. You must make this a single line string with explicit The output, which you will paste into your config file, should appear something like: -----BEGIN RSA PRIVATE KEY-----\nMIICXAIBAAKBgQCqGKukO1De7zhZj6+H0qtjTkVxwTCpvKe4eCZ0FPqri0cb2JZfXJ/DgYSF6vUp\nwmJG8wVQZKjeGcjDOL5UlsuusFncCzWBQ7RKNUSesmQRMSGkVb1/3j+skZ6UtW+5u09lHNsj6tQ5\n1s1SPrCBkedbNf0Tp0GbMJDyR4e9T04ZZwIDAQABAoGAFijko56+qGyN8M0RVyaRAXz++xTqHBLh\n3tx4VgMtrQ+WEgCjhoTwo23KMBAuJGSYnRmoBZM3lMfTKevIkAidPExvYCdm5dYq3XToLkkLv5L2\npIIVOFMDG+KESnAFV7l2c+cnzRMW0+b6f8mR1CJzZuxVLL6Q02fvLi55/mbSYxECQQDeAw6fiIQX\nGukBI4eMZZt4nscy2o12KyYner3VpoeE+Np2q+Z3pvAMd/aNzQ/W9WaI+NRfcxUJrmfPwIGm63il\nAkEAxCL5HQb2bQr4ByorcMWm/hEP2MZzROV73yF41hPsRC9m66KrheO9HPTJuo3/9s5p+sqGxOlF\nL0NDt4SkosjgGwJAFklyR1uZ/wPJjj611cdBcztlPdqoxssQGnh85BzCj/u3WqBpE2vjvyyvyI5k\nX6zk7S0ljKtt2jny2+00VsBerQJBAJGC1Mg5Oydo5NwD6BiROrPxGo2bpTbu/fhrT8ebHkTz2epl\nU9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ\n37sJ5QsW+sJyoNde3xH8vdXhzU7eT82D6X/scw9RZz+/6rCJ4p0=\n-----END RSA PRIVATE KEY----- EDIT: The above instructions are incorrect. Please see the proper way to generate a key further down this thread |
When I type the command I use the guide: https://yasoob.me/posts/running_staticman_on_static_hugo_blog_with_nested_comments/# (Readme does not help me much) |
Try using the heroku web interface rather than the command line. See instructions at this link under the section "Managing config vars" and the subsection "Using the Heroku Dashboard". |
Thank you. I just don't know how to change files like |
I'm sorry, I don't know what you are referring to. I'm not aware of any |
The
|
You do not need that file. That guide you are following is outdated and the "Deploy to Heroku" button does much of that for you. Again, all you should need to do is click that deploy button from our README and then add your config variables. |
I did as in the guide in readme - I entered the first command (on the Herok website) EDIT: |
That section of the README is referring to running the server on your own infrastructure. Those steps are not necessary when using Heroku. Again, the only steps you need to follow to deploy to heroku are clicking the deploy button and entering your config variables. |
Once you have clicked the "Deploy to Heroku" button, you will be redirected to the Heroku page. Here you will give your instance a name and click deploy. Once this has finished, click the "Manage App" button at the bottom of the screen. At the top there will be a tab called "Settings" which you will click. On the settings page, click "Reveal Config Vars" and add the configuration values for your instance. |
I did as you said. I added those values. I don't know if you need to add |
You can check your logs to try to see what exactly went wrong. I believe you must set a value for the port config value as well. I don't believe a NODE_ENV is necessary. Without access to the logs it is hard for me to tell exactly what is wrong with your setup. |
The logs don't tell anything. I copied everything that showed up there. |
Hmm I went to try to deploy the entire thing myself and am encountering similar issues with the RSA key. I will reopen this issue and investigate when I have time. |
@IgorKowalczyk apologies, I believe my previous instructions for generating an RSA key were incorrect. The RSA_PRIVATE_KEY value you provide to Heroku should not have any To summarize:
Your key as entered into Heroku should look something like this: -----BEGIN RSA PRIVATE KEY-----MIICXAIBAAKBgQCqGKukO1De7zhZj6+H0qtjTkVxwTCpvKe4eCZ0FPqri0cb2JZfXJ/DgYSF6vUpwmJG8wVQZKjeGcjDOL5UlsuusFncCzWBQ7RKNUSesmQRMSGkVb1/3j+skZ6UtW+5u09lHNsj6tQ51s1SPrCBkedbNf0Tp0GbMJDyR4e9T04ZZwIDAQABAoGAFijko56+qGyN8M0RVyaRAXz++xTqHBLh3tx4VgMtrQ+WEgCjhoTwo23KMBAuJGSYnRmoBZM3lMfTKevIkAidPExvYCdm5dYq3XToLkkLv5L2pIIVOFMDG+KESnAFV7l2c+cnzRMW0+b6f8mR1CJzZuxVLL6Q02fvLi55/mbSYxECQQDeAw6fiIQXGukBI4eMZZt4nscy2o12KyYner3VpoeE+Np2q+Z3pvAMd/aNzQ/W9WaI+NRfcxUJrmfPwIGm63ilAkEAxCL5HQb2bQr4ByorcMWm/hEP2MZzROV73yF41hPsRC9m66KrheO9HPTJuo3/9s5p+sqGxOlFL0NDt4SkosjgGwJAFklyR1uZ/wPJjj611cdBcztlPdqoxssQGnh85BzCj/u3WqBpE2vjvyyvyI5kX6zk7S0ljKtt2jny2+00VsBerQJBAJGC1Mg5Oydo5NwD6BiROrPxGo2bpTbu/fhrT8ebHkTz2eplU9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ37sJ5QsW+sJyoNde3xH8vdXhzU7eT82D6X/scw9RZz+/6rCJ4p0=-----END RSA PRIVATE KEY----- |
@basemwahba yes, although your application doesn't have to be public. It can be created for just your account when you fill out the form to create a new GitHub application. |
Yeah. The key needs spaces (new lines) I didn't have them. After generating the key with PuTTy and copying it with N++ and pasting it into PS: I want to use v2 API, however, seems better to me and it works the same (I guess), no need to add (and create new) applications. |
@IgorKowalczyk in your connect call, the username should be that of your bot account not your main account. The connect endpoint is meant to make your bot account accept the collaborator invite. |
https://api-igorkowalczyk.herokuapp.com/v2/connect/igorkowalczykbot/blog? But it show the same message. |
@IgorKowalczyk I was wrong, it should be your normal account name and not the bot account. The correct form is a GET request to https://api-igorkowalczyk.herokuapp.com/v2/connect/igorkowalczyk/blog You can try revoking and resending the invitation. Watch the Heroku logs too to see if anything errors are being thrown there. Worst case, you can log in to the bot account and manually accept the invite. |
Post when i try: https://igorkowalczyk.github.io/blog//internet/2020/01/22/Bezpieczeństwo-w-sieci-nasze-dane.html |
@alexwaibel first of all, thank you for all your support here. I am running my own staticman instance on heroku as well, and trying to get it to work with my github pages blog. I was previously trying to use
Any help on this would be really appreciated. |
@IgorKowalczyk I'm not really sure what you're asking. That sounds like a problem with how you're submitting the comment form from your website. @ElArkk Those URLs should be the URL of your staticman instance I believe. I don't think it really matters in this case though. As far as the config values, to run as a GitHub app you'll need rsaPrivateKey, githubAppID, and githubPrivateKey. Note these are two separate private keys. |
I'm asking because my script can't send a request to api (and from that I don't know if this API works) The script below: const commentForm = document.querySelector('.commentform');
const commentFormInputs = document.querySelectorAll('.commentform-input');
const slugInput = document.querySelector('.commentform-input-slug');
const optionsSlugInput = document.querySelector('.commentform-input-optionsslug');
const nameInput = document.querySelector('.commentform-input-name');
const emailInput = document.querySelector('.commentform-input-email');
const messageInput = document.querySelector('.commentform-input-message');
const errorMessagesDiv = document.querySelector('.commentform-errormessages');
const sendFailedDiv = document.querySelector('.commentform-sendfailed');
const sendSucceededDiv = document.querySelector('.commentform-sendsucceeded');
const url = 'https://api-igorkowalczyk.herokuapp.com/v2/entry/igorkowalczyk/blog/master';
function post(url, data, callback, errorCallback) {
const xhr = new XMLHttpRequest();
xhr.open('POST', url);
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xhr.onload = function() {
if (xhr.status === 200) {
callback(xhr.responseText);
} else if (xhr.status !== 200) {
errorCallback(xhr.responseText);
}
};
xhr.send;
}
if (commentForm) {
commentForm.addEventListener('submit', (e) => {
e.preventDefault();
errorMessagesDiv.innerHTML = '';
sendFailedDiv.style.display = 'none';
sendSucceededDiv.style.display = 'none';
const slug = slugInput.value.trim();
const optionsSlug = optionsSlugInput.value.trim();
const name = nameInput.value.trim();
const email = emailInput.value.trim();
const message = messageInput.value.trim();
let error = false;
let fatalError = false;
const messages = [];
if (name.length < 2) {
error = true;
messages.push('<div class="commentform-errormessage">Proszę wpisać imię.</div>');
}
if (email.search(/^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/) === -1) {
error = true;
messages.push('<div class="commentform-errormessage">Proszę wpisać poprawny e-mail.</div>');
}
if (message.length < 2) {
error = true;
messages.push('<div class="commentform-errormessage">Proszę wpisać wiadomość.</div>');
}
if (fatalError) {
return false;
}
if (error) {
errorMessagesDiv.innerHTML = messages.join('');
return false;
}
const params = [];
for (let i = 0; i < commentFormInputs.length; i++) {
const input = commentFormInputs[i];
params.push(`${ input.name }=${ input.value }`);
}
post(
console.log("Hello world!"),
e.target.getAttribute('data-action'),
params.join('&'),
function(text){
commentForm.reset();
sendSucceededDiv.style.display = 'block';
},
function(text){
sendFailedDiv.style.display = 'block';
}
);
});
} And HTML (Rendered, Unrendered) here: |
@IgorKowalczyk you can try sending the request to the API directly with a REST client like Postman to see if the request is working as expected. From there try replicating that request in your front-end code. The postman request would look something like: I'd first try to just use the bare HTML form for submissions and then once you've got that working you can start adding back in the javascript stuff. |
@alexwaibel thank you! I'm still somehow getting MISSING_CONFIG_BLOCK errors, which I think can get thrown because of multiple underlying reasons. However, I got |
@alexwaibel But I don't care if the API works anymore, the JS script sends out the requests badly, I don't know what to do... I reworked it a little bit to send requests from one API, but it still doesn't display any errors. Maybe it's the fault of this element: post(
console.log("Hello world!"),
e.target.getAttribute('data-action'),
params.join('&'),
function(text){
commentForm.reset();
sendSucceededDiv.style.display = 'block';
},
function(text){
sendFailedDiv.style.display = 'block';
}
);
});
} I added console.log there to check if the script works there. |
@IgorKowalczyk well, this repo is strictly for fixing issues found in the Staticman API. I'm sorry, but I don't have the time to go through your project (and everyone else's that posts here) and figure out what's wrong with your front-end code. As I suggested previously, I'd recommend going to bare HTML submission first to get the bare minimum comment submission functionality working and then you can start adding back in the javascript features you'd like to use. Additionally, the JS fetch API makes dealing with requests easier than using XMLHttpRequests in my opinion. You might find this Stack Overflow post to be helpful. |
Hi @alexwaibel! I followed your instructions in this comment, but I'm getting a 2020-03-22T18:01:39.749062+00:00 app[web.1]: (node:24) UnhandledPromiseRejectionWarning: Error: error:0909006C:PEM routines:get_name:no start line
2020-03-22T18:01:39.749084+00:00 app[web.1]: at Sign.sign (internal/crypto/sig.js:112:29)
2020-03-22T18:01:39.749084+00:00 app[web.1]: at Object.sign (/app/node_modules/jwa/index.js:152:45)
2020-03-22T18:01:39.749085+00:00 app[web.1]: at Object.jwsSign [as sign] (/app/node_modules/jws/lib/sign-stream.js:32:24)
2020-03-22T18:01:39.749085+00:00 app[web.1]: at Object.module.exports [as sign] (/app/node_modules/jsonwebtoken/sign.js:204:16)
2020-03-22T18:01:39.749086+00:00 app[web.1]: at getSignedJsonWebToken (/app/node_modules/@octokit/app/dist-node/index.js:31:30)
2020-03-22T18:01:39.749086+00:00 app[web.1]: at GitHub._authenticate (/app/lib/GitHub.js:58:21)
2020-03-22T18:01:39.749086+00:00 app[web.1]: at /app/lib/GitHub.js:31:32
2020-03-22T18:01:39.749088+00:00 app[web.1]: at new GitHub (/app/lib/GitHub.js:46:7)
2020-03-22T18:01:39.749089+00:00 app[web.1]: at Object.module.exports.create (/app/lib/GitServiceFactory.js:11:14)
2020-03-22T18:01:39.749089+00:00 app[web.1]: at /app/lib/Staticman.js:32:35
2020-03-22T18:01:39.749089+00:00 app[web.1]: at new Staticman (/app/lib/Staticman.js:46:7)
2020-03-22T18:01:39.749090+00:00 app[web.1]: at module.exports (/app/controllers/process.js:126:27)
2020-03-22T18:01:39.749090+00:00 app[web.1]: at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
2020-03-22T18:01:39.749090+00:00 app[web.1]: at next (/app/node_modules/express/lib/router/route.js:137:13)
2020-03-22T18:01:39.749091+00:00 app[web.1]: at /app/server.js:169:14
2020-03-22T18:01:39.749091+00:00 app[web.1]: at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
2020-03-22T18:01:39.749091+00:00 app[web.1]: at next (/app/node_modules/express/lib/router/route.js:137:13)
2020-03-22T18:01:39.749091+00:00 app[web.1]: at /app/server.js:144:14
2020-03-22T18:01:39.749092+00:00 app[web.1]: at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
2020-03-22T18:01:39.749092+00:00 app[web.1]: at next (/app/node_modules/express/lib/router/route.js:137:13)
2020-03-22T18:01:39.749092+00:00 app[web.1]: at /app/server.js:129:14
2020-03-22T18:01:39.749093+00:00 app[web.1]: at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
2020-03-22T18:01:39.749171+00:00 app[web.1]: (node:24) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 3)
2020-03-22T18:01:39.749239+00:00 app[web.1]: (node:24) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
2020-03-22T18:02:09.723405+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=POST path="/v3/entry/github/esporo/esporo/master/comments" host=esporo-staticman.herokuapp.com request_id=ebdaa58b-cb1f-4ceb-9a5e-dfd5997bdc2e fwd="138.36.184.66" dyno=web.1 connect=0ms service=30001ms status=503 bytes=0 protocol=https This only happens when trying to use the v3 endpoint, v2 works fine. |
@arthrfrts which endpoint specifically are you trying to use? |
@alexwaibel I'm trying to connect using |
I have the same issue. Does anyone have a fix for it? |
@arthrfrts @HarishMunagapati sorry I disappeared in the middle of assisting you with this. I've been quite busy lately and haven't had the necessary bandwidth to devote to this project. For now I'd recommend using v2 and authenticating using a token as that's the most stable and documented approach. |
Sure, I'll reconfigure with v2 and comeback. When I did it yesterday, it's not showing the comments below the page. |
@alexwaibel @mmistakes Even v2 is not working now, can you please help me with documentation I'm using Minimal Mistakes, latest release v4.19.2 |
@HarishMunagapati take a look at these resources: |
@alexwaibel I went trough them over multiple times from for last weekdays 😄 Here is things confusing me. staticman_url: https://${bridge_app_name}.herokuapp.com/v2/entry/${github-username}/${blog-repo}/master/comments and in "https://spinningnumbers.org/a/staticman-heroku.html" its mentioned as staticmanUrl: https://spinningnumbers-staticmandev2.herokuapp.com/v2/entry/willymcallister/willymcallister.github.io/master/comments either of them didn't who any logs in my Heroku app and I see the error But luckily today, this worked for me @mmistakes can update in the configuration document. Now I'm trying to figure out nested comments. |
I had the same error ... I made my rsa private key in one line, without space and br |
@alexwaibel I just saw your comment and I would like to clarify that it's OK to have both of the parameters. My GitHub and GitLab (demo) projects linked to @staticmanlab using the same Heroku app name provide a proof. However, I'm now reading about the recent developments so as to replace my old instance open to public with a personal one. |
Hello, I’ve been trying to make staticman run on my github page for a couple hours.
I hope it was clear enough, if not feel free to ask for more information. |
|
When I try to send data to your API that works on Heroku, I get an "Application error" message just like in the picture.
You will restore an older version, or fix the hosting of your application on Heroku, because I think it's your fault, not my form.
The text was updated successfully, but these errors were encountered: