Express.js know where link to page was clicked - express

Where in the req object can I see where I came from in Express.js.
Say I have the same navbar on every page of my site, but I click on a link in that navbar. Under certain conditions, I want to redirect to the calling page instead of going to the clicked link. In the middle where for those routes I should be able to find what page I clicked on the link at in the request object, am I right?

Referer is what are you looking for. Inside your controller, If you console.log(req.headers) you will see a property referer containing the address of the previous web page.
So, in case you want to redirect back you can use this res.redirect(req.headers.referer);

Related

VueJs Address Bar

Hi friends,
The company I work for has a website with an Admin Dashboard. Pages that users can use according to their authorization are listed in the menu. Beautiful so far. However, there is a problem. The person can reach the pages that he cannot see in the menu at the moment, without authorization, from the address bar, by entering the link of the page. How can I prevent access to unauthorized pages from the Address Bar by redirecting them from one place? I don't want to check each page individually. This doesn't make sense. For example, a component with the message "You are not authorized to view this page" may be displayed or automatically redirected to the home page.
I'm waiting for your help. Thanks.
You will need to use a global router navigation guard/hook called beforeEach - as explained in multiple tutorials:
https://css-tricks.com/protecting-vue-routes-with-navigation-guards/
https://www.permify.co/post/implementing-role-based-access-control-in-vue-js

On Nuxt-Link click refresh page if same url

For example, I have a blog website, with a discover page that doesn't take any params. When you load page fetch hook calls API that randomly returns some article.
So my problem is when I'm already on the Discover page and I click discover in the Left bar I want the page to refresh.
:key="$route.fullPath" is not working for me because nothing is changing in the path.

Why sitefinity list allows wrong page url or allows paging?

I am using sitefinity 10.1 MVC. When I used sitifinity list on my page then it allow my page to go to wrong URL. For example, my page link is www.example.com and when I try www.example.com/12, instead of taking me to 404 error page it allows this URL and lands on the actual page. I need to take www.example.com/12 to 404 page.
That's because the "Enable Parameter Validation" setting is checked (by default).
When it is checked, Sitefinity leaves the widgets on the page to determine whether they can handle this page or should return 404.
Until a widget says "no, I can't and should not handle this page", a normal page is returned. The List widget is not one that would complain in this case.
It overrides the HandleUnknownAction where it simply invokes the Index action of the controller and says "I am good with this page, you do what you want with it".
So what you can try is going to Title and Properties of the page and scroll down, expand the Advanced options and uncheck Enable Parameter Validation. Save and try again.

fixed url on address bar - show only base url http://www.mysite.com

I need to show on the address bar just the first part of the url of my site.
For example for any page with name like
http://www.mysite.com/mypage.php or
everything else
I want to see just http://www.mysite.com on the address bar of the browser.
How this can be achieved?
I tried with apache RewriteRule but with no result.
Apart from being a really bad idea for people actually trying to use your site, there is no way you can do this on the server side, because the server needs to know which page was accessed - that's what a URL is for. What you are looking for is to make it appear to the user that they are still at the same URL.
This is easy enough if you put your entire site in an HTML frameset with one frame, or an iframe sized to fill the browser window. This does require all external links to have target="_top", and without additional JS people can break out of the frame and access the pages individually anyway.
An alternative approach, that will only work on some browsers, would be to use history.pushState to fake the address bar back to / every time a new page loads.

Open graph: custom actions

I created a custom action and object.
The only problem I have is when publishing to FB, clicking on the icon or on the title redirect the user to a blank page instead of my application.
Where can I set the redirect link?
The only url I see is the one in the opengrap html but this one is suppose to be the adress of the og wright? (
This link might help.
Basically, when the opengraph action is executed by your app, it sets the url that represents the object (which provides all the metadata for the object) and is also the URL that a user is sent to when they click the action in facebook.
E.g. https://graph.facebook.com/me/[YOUR_APP_NAMESPACE]:cook
?recipe=OBJECT_URL&access_token=ACCESS_TOKEN
In this case, the cook action is being called, with a recipe object with the given OBJECT_URL. At that url, a page should exists (generated by you), with all the facebook metadata in the head tag so that the object can be correctly created, but also with actual web page data for the user to view.
Another link worth looking at for a working example is here