When using Vuepress behind a Remote App Server, pages containing iframes may return a 404 error

Creating a static website using Vuepress was a breeze, especially since I included a dedicated section for embedded Tableau dashboards. The website functioned perfectly when accessed online without any issues, displaying the Tableau dashboards flawlessly.

However, complications arose when I published the website as a remote application behind my company's firewall. An authentication layer added an extra URL component, changing it from https://mywebsite.mycompany.com to

https://privateapps.mycompany.com/https/mywebsite.mycompany.com

The problems began with the homepage redirecting to Vuepress' 404 page upon landing, but refreshing the page fixed this. While most pages worked fine, those containing the Tableau iframe consistently redirected to the 404 error page.

I suspected a server-side rendering (SSR) issue and attempted to mitigate it by utilizing the vuepress-plugin-dehydrate. However, neither the noSSR nor the noScript options provided a satisfactory solution. The latter option removed all JavaScript files, rendering the iframes useless.

A perplexing conflict related to redirection seemed to persist, even after experimenting with the nginx configuration and adding a location directive. The warning message displayed on the page while operating behind the remote app only added to the confusion.

 server {
     # listen on port 80 (http)
     listen 80;
     server_name _;

     root /usr/share/nginx/html;

    location / {
      try_files $uri$args $uri$args/ index.html;
    }

 }

Frustrated by these technical challenges, I am now seeking valuable insights or solutions from others who may have encountered similar hurdles.

https://i.sstatic.net/T3zkX.png

If you can offer guidance or assistance in resolving these issues, it would be greatly appreciated.

Answer №1

After extensive troubleshooting, I successfully resolved my own query. The solution turned out to be surprisingly simple and elegant.

The issue causing trouble on the vuepress site was due to changes made by PaloAlto, the remote app provider behind the firewall. They were altering the URL to something like

https://privateapps.mycompany.com/https/mywebsite.mycompany.com
. This addition of /https/mywebsite.mycompany.com confused the vuejs router into mistaking it for a path that needed resolving instead of recognizing the base of the app.

To fix this, I implemented an App Level Enhancement in vuepress which involved the following steps:


    export default ({
      Vue,
      options,
      router,
      siteData
    }) => {

      router.beforeResolve((to, from, next) => {

        const editable = ['/https/mywebsite.mycompany.com']

        let flag = editable.filter(i => to.fullPath.startsWith(i))

        if(flag.length > 0){
          const newPath = to.fullPath.replace(flag[0],'/');
          next(newPath);
        }else {
          next();
        }

      })
    }

The solution involved using a navigation guard router.beforeResolve which executes just before navigation is confirmed, after all component guards and async route components have been resolved.

In addition to this, I also made improvements to my nginx configuration by following recommendations outlined in this post:

    server {
      listen 80 default_server;
      listen [::]:80 default_server;

      root /your/root/path;

      index index.html;

      server_name your.server.com;

      location / {
        try_files $uri $uri/ @rewrites;
      }

      location @rewrites {
        rewrite ^(.+)$ /index.html last;
      }

      location ~* \.(?:ico|css|js|gif|jpe?g|png)$ {
        expires max;
        add_header Pragma public;
        add_header Cache-Control "public, must-revalidate, proxy-revalidate";
      }

    }

I share this experience with the hope that it may assist others facing similar challenges, as troubleshooting this issue was quite frustrating.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Performing an API request and saving the response data into a

I’m struggling to figure out how to make an API call with request in MongoDB using Mongoose. I’m new to this topic and could really use some help! Here is my test.js file, does anyone have any ideas on how to solve this issue? My goal is to save the AP ...

Can all browser console messages and errors be sent to a different machine using a pipeline?

Currently, I am in the process of troubleshooting a javascript error that is occurring within a Cordova app's InAppBrowser on an Android device. Despite being able to connect to the web-view on the phone using Chrome's remote debugging tools, the ...

Converting Strings to Booleans in Vue: A Dilemma

Within my Vue HTML code, I have the following: <v-textarea auto-grow="true"></v-textarea> The functionality works as intended, with the textarea expanding automatically. However, it does trigger an error message: [Vue warn]: Invalid ...

Guide on creating event hooks within VUE 2.0 component connections

I have successfully created two dynamic components. Now, I am looking to trigger the "logThat(someObj)" method of component-two using events: $emit/$on with the arguments being passed as shown in this code snippet: Vue.component('component-one', ...

What are some effective strategies for enhancing the performance of React user interfaces?

I'm currently dealing with a performance challenge in one of my React applications. What are some best practices to enhance the responsiveness of the User Interface? One approach could be to minimize the usage of conditional expressions like { carIsR ...

What is the best way to navigate through an HTML node tree, including all of its sub elements, when walking through

Do you know of a way to iterate through the entire hierarchy of HTML elements and check each one for attributes and more without using JavaScript? We currently have a JavaScript solution that iterates through each child element and all their descendants. ...

Decreased storage space requirements following transfer to S3 bucket using nodejs

I am currently facing an issue with uploading files from a specific folder location to an S3 bucket using the nodejs aws-sdk. The files I am working with are deepzoom images (.dzi). While the files seem to be successfully uploaded to my S3 bucket, I have n ...

Create an AngularJS task manager that saves your to-do list even when the page is refreshed

Currently, I am developing a straightforward to-do list application using AngularJS within an ASP.NET MVC template. Surprisingly, I have successfully integrated Angular and Bootstrap to achieve the desired functionality. The app allows users to add and re ...

How can you use DOM manipulation to extract input data from an <input type="file"> element?

Is there a way to retrieve the data from an <input type="file"> element, specifically if it contains an image, without utilizing an html form? Here is the HTML code: <body> <input type= "file"> </body> ...

An Axios error message indicates ERR_NETWORK and ERR_EMPTY_RESPONSE

When I initiate a Patch Request from the frontend, it takes approximately 30-40 seconds for the backend to resolve. const handleSendClick = (data: any) => { const requiredLanguages = Array.isArray(data.required_languages) ? data.required_langu ...

organizing arrays with the structure name:url

I have a list of string URLs like "http://dom/image1.jpg","http://dom/image2.jpg" that I obtained from an API which returns only the links. However, the plugin I am using requires the array to be in a specific format: {image:"http://dom/image1.jpg"},{imag ...

Incorporating outside content into HTML

Currently, I am working on a project at my job which requires me to create a comprehensive help file with multiple chapters and extensive text all within one large HTML file. However, as the text will need to be translated into different languages, I am lo ...

Toggle between a list view and grid view for viewing photos in a gallery with a

Hey there, I'm a newbie on this site and still getting the hang of jQuery and JavaScript. Though I do have a good grasp on HTML and CSS. Currently, I'm working on a photo gallery webpage as part of my school project using the Shadowbox plugin. Wh ...

Encountering difficulty in creating a Nuxt website using @googlemaps/js-api-loader

While using the @googlemaps/js-api-loader in my Nuxt 3 website, I encountered an issue. Everything worked perfectly during local development. However, when I attempted to build the project with nuxt generate (whether locally or on Vercel), I received the f ...

When the enter key is pressed in a contenteditable div, line breaks are disregarded

Is there a way to ensure that when the return key is pressed to start a new line for a post, the output actually starts on a new line? I've been having trouble with this and would like to know the most common solution. Check out the demo below for te ...

Assigning a class to an li element once the page has finished loading

I am facing an issue with my navigation bar where the links are dynamically loaded from a database using a foreach loop. Although the nav bar is static, I want to apply an 'Active' class to the link when it is currently active. Despite trying to ...

Unable to locate the element with the specified id: <path>

I am aiming to dynamically change the fill attribute of a specific <path> element when a page loads. Here is the detailed information about the path element: <path xmlns="http://www.w3.org/2000/svg" style="fill:#ff0000;stroke:#000000;stroke-wid ...

An animation triggered by scrolling using the @keyframes rule

Is it possible to smoothly animate a variable font using @keyframes on scroll and have it complete the animation loop when the user stops scrolling, rather than snapping back to the starting position? I've managed to make the animation work, but it l ...

Replicate and $(document).ready()

My form has required fields that need to be completed. To alert users about blank fields, I have implemented the following code: $(document).ready(function() { $('input.required:text').focus(function() { $(this).css({'background ...

Access my account on the one.com control panel using the identical login credentials

I am curious if it's possible to implement a login page on my website for customers and then seamlessly redirect them to the control panel on one.com without requiring them to re-enter their username and password? Visit the action page on one.com her ...