Accessing HttpHeaders

0
Hi All,   I hope you are all enjoying your summer and also that some of you are still available to help me with the following question.   I have created a public portal and have set my ‘default home page’ to a Microflow that simply checks for deep links and opens a page. Now I want, besides the everyday visitors, make the content of my portal also available to (crawlers of) search engines. Unfortunately, these search engines are not so fond of the Javascript pages that are generated by Mendix. Therefor I want to redirect the crawlers to HTML-versions of my pages, based on the ‘host’ and ‘user-agent’ values in the HttpHeaders. However, these headers don’t seem to be accessible like they are in published REST-Services., When you are using a page or Microflow in the navigation it is not permitted to use input variables (which I can understand), so unfortunately also not the HttpRequest object. In the Microflow it is also not possible to retrieve the Http-objects, because these objects don’t seem to be available. Does anyone knows how to access the HttpHeaders or has a smarter solution to achieve my goal?   Thank you in advance for your help and have a nice day!   Kind regards, Martijn
asked
2 answers
0

Martijn,

I have used a Javascript action to get the href and, based on the value, redirect to the page I want the user to go to.  Some details:

Here is my default home page:

The Microflow Timer calls this nanoflow which looks for a specific URL (custom domain) that was used to navigate to the app:

The Javascript action code is as follows:

 

We used this to show a different page to users who arrived via a specific custom domain.

 

I realize this is not exactly what you are trying to accomplish, but thought it might give you a starting point.

 

Hope that helps,

Mike

 

answered
0

Mike, You Rock! This was de push in right direction I needed! I added a JavaScript action to my Page with the code:

 

»

 

export async function JavaScript_Read_Request_UserAgent() {

// BEGIN USER CODE

var userAgent = window.navigator.userAgent;

return userAgent;

 

// END USER CODE

}

 

«

 

This gives me exactly the information I need to check if the visitor is a search bot and then redirect it to the HTML files.

 

Thank you for your help and have a nice day!

 

Best,

Martijn

answered