Messages are gone when page refresh - pubnub

I am try to use this GitHub repo: https://github.com/jskrepnek/chatiNG
I adapted it to my website and everything is fine but except messages are gone when I refresh the page. I add restore:true to subscribe but that didn't work. My website is AngularJS based. So what causes this?

Related

Refreshing Angular app breaks one component, but only on version hosted on Heroku

I am working on a personal project for my portfolio and I'm completely stuck.
I have an Angular 14 app I've been working on. The stack is PEAN. I currently have a live version of it hosted on Heroku. The issue I'm running into is that in my local development version of the app, everything works as intended, however on the live version on Heroku, If I refresh the page using f5 while on the main backlog page, it does not refresh, and instead shows a blank page with "[ ]" at the top of the page. Every other part of the app functions fine, and it does not fully crash when I run into this issue. If I type a different URL in and go to that page, it works again. If after doing so, I click a link that loads the crashed component, it will reload just fine. It appears that the component only breaks if I refresh the component with f5 (or clicking the refresh button on chrome).
I've been working on this for a long time and I think I've narrowed it down a bit. So far I've:
confirmed that my express server is serving my static HTML files from their folder correctly
added a catch all code block at the bottom of my express file to redirect to index.html
made sure that Heroku was actually executing my server.js file
removed potential offending portions of code, like auth/error interceptors and newly added Google Sign-in
I've also:
checked with various browsers/mobile browsers
checked for console errors (there are none)
checked network tab on refresh. (just shows a 304-OK response)
checked Heroku logs. No errors there either.
The issue can not be recreated locally, and it only happens on refresh of one component, the Backlog component.
If there is any more info I can add please let me know, I'm hoping this is a regularly encountered issue. I can't seem to find anything that specifically deals with my exact issue by searching. Any help is greatly appreciated.
update
The blank page with "[ ]" appears to be my database's response when hit without a user ID to check against, and return data. I've narrowed this down to an HTTP-INTERCEPTOR that injects the user ID into the headers, which the route that would use that info for the DB wouldn't have. This makes my DB return "[]".
The only thing I don't understand is that this happens only when hosted on heroku, and not locally.

Making a forum using Node Express EJS and MongoDB

I am making a forum using Node, Express, EJS and MongoDB. Currently, I render the forum page and pass data from the database using Node and EJS. I use GET and POST requests. As soon as I add a comment, the page stores in the database and then redirects back to the same route. I am then able to scroll down and see my comment. However I am not happy with this and I want the comments and replies to be handled by Ajax so that as soon as I comment, without refreshing, I create a post request and again without refreshing the page I can load the new comment. Any suggestion on how can I bring this to live?
The project is available to view on https://github.com/Ibrahim40021974/Forum . (Sorry for the untidy code. Am still working on version control). All suggestions are welcomed!
Thanks in Advance.
What you wanna achieve, is generally called a single page application where you won't see the page refresh but the small component of that page is actually got updated with new data.
I have done using Reactjs, Nodejs which is pretty easy to do in Reactjs. If you are interested , I can share the repo.
Had looked into your project and few things I noted.
If I am referring the right one (https://github.com/Ibrahim40021974/Forum/blob/master/views/forum.ejs#L69) then you need to stop default form submit using e.preventDefault(). Default form submit always refresh the page which you don't want. Same form operation you have to do with ajax call.For exm.
handleFormSubmit(e) {
e.preventDefault();
// <add your ajax call here>
}
See once you do this if things work without page refresh.
See if this helps you with how to make ajax call. https://www.thetopsites.net/article/53326172.shtml
As #Ajay kumar said the best way is to create a single page app : framework like react/angular/vue are pretty good when it's about refreshing only part of your page when new data are inserted.
Yet you could do this without using any of this framework but it will be tricky.
You can, in your ejs template add the javascript logic that will, when you submit your comment, do the following :
Send a post request to submit the new comment
Send a get request to get comment affiliated to this post as soon as post request ended
update the DOM(vanillaJs or Jquery) to display the list of comment.
The first choice will ask you to change your project architecture, but will be easier to manage, the second will give you the possibiliy to keep using ejs but is a bit more complicated.

Requests to the server have been blocked by an extension

I am trying to save OAuth tokens for a chrome extension. I have created a page where a javascript code runs which fetches the tokens from the URL and saves them to chrome's local storage. It was working fine until recently and now when it redirects to that page, it displays an error Requests to the server have been blocked by an extension. When I manually refresh the page, the error is gone and the script works fine. I tried location.reload() w/o true & setting location.href in the javascript code, nothing seems to be working.
I have two questions
How to avoid this error?
Is there a better to store OAuth credentials? The documentation seems to be outdated.

LINE login api authentication doesn't work after I've accepted the agreement

I'm developing a web app using node.js and use ejs as my view engine.
On my login page, I am trying to intergrate LINE login in my system.
I followed the instructions and tried run on the the login querystring in the following order,
access.line.me/dialog/oauth/weblogin?response_type=code&client_id={My Channel ID}&redirect_uri=https://localhost:3000/login&state=login
but the page shows "Can not connect to this site page." Tried refresh many times and it is still not working.
I've tried looking for the issue, but I still don't get why my login page is not showing up. Did I do anything wrong?
Thanks ahead
I think u cant use localhost url as your login url, it must be hosted and have https security

Retrieve BLOGS_UPLOADED_IMAGES in java

I have some java code that retrieves blogs through the REST API's. I am not using the social business toolkit, but we have our own framework for that.
The application works perfectly on an on-premise connections environment and has worked on multiple versions.
However when switching to Connections Cloud, some parts stopped worked.
We get a 403 - Forbidden exception on 2 occasions:
Getting the details of a blog post: /blogs/[blog-id]/feed/entry/atom?entryid=[entry-id]
Getting images inside the blog post: /blogs/[blog-id]/resource/BLOGS_UPLOADED_IMAGES/[image file name]
I have fixed issue 1) by switching to the plublishing API: /blogs/[blog-id]/api/entries/[entry-id].
I cannot find a way to fix issue 2). I have also found 2 other image urls:
https://apps.ce.collabserv.com/blogs/[blog-id]/api/media/[file-name]
https://apps.ce.collabserv.com/blogs/[blog-id]/api/media/BLOGS_UPLOADED_IMAGES/[file-name].media
Both return:
<sp_0:error xmlns="http://incubator.apache.org/abdera" xmlns:sp_0="http://incubator.apache.org/abdera">
<code>404</code>
<message>Not Found</message>
</sp_0:error>
I want to authenticate by using Basic Authentication when possible. This does not appear to work with the given 403 urls.
My guess is that this the basic authentication header is not picked up. I have seen this before.
I used to fix this by first calling another URL that does support basic authentication and using the Ltpa cookies to authenticate the image url.
This also does not work: I do get LtpaTokens, but when I pass all the cookies to the URL, the image still does not work.
I prefer not to use OAuth of OAuth 2 at this moment. Is there any other way to fix this?
Anybody else managed to retrieve BLOGS_UPLOADED_IMAGES?
The issue is can also be reproduced in a browser.
Make sure you are not yet authenticated and the blog has posts with
images
Go to /blogs/[blog-id]/api/media
Authenticate using the popup in the browser The Atom feed now appears. This contains the images of your blog.
403 when opening:
/blogs/[blog-id]/resource/BLOGS_UPLOADED_IMAGES/[image]
404 xml when opening: /blogs/[blog-id]/api/media/* links

Resources