Experiencing an Issue with NGINX Loading Vue 3 Vite SPA as a Blank White Page

I currently have the following NGINX configuration set up:

events {
    worker_connections 1024;
}

http {
    server {
        listen 80;
        server_name localhost;

        location / {
            root C:/test;
            index index.html;
            try_files $uri $uri/ /index.html;
        }

        location /display/outbound {
            alias C:/test/display/outbound;
            index index.html;
            try_files $uri $uri/ /display/outbound/index.html;
        }

        location /display/outbound/api/ {
            proxy_pass http://localhost:52000/api/;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }

        # Setting MIME types for .js and .css files
        types {
            text/html html;
            application/javascript js;
            text/css css;
        }

        # Serving static assets
        location /assets/ {
            alias C:/test/display/outbound/assets/;
        }

        # Serving favicon
        location /favicon.ico {
            alias C:/test/display/outbound/favicon.ico;
        }
    }
}

The configuration has three main aspects:

  • The route http://localhost returns a static HTML page with only an h1 element, which is functioning correctly.
  • A Vue 3 Vite Single Page Application hosted at http://localhost/display/outbound. The files seem to be served properly as indicated in the network tab of dev tools without console errors, but only displays a blank white page.
  • A reverse proxy to my API - This worked fine when serving the Vue app from http://localhost.

I'm struggling to figure out why the Vue app works when served from http://localhost, but not from http://localhost/display/outbound.

If anyone can provide guidance or suggestions on how to resolve this issue, it would be greatly appreciated.

Edit - My directory structure is as follows:

  • C:/test - Root directory
  • C:/test/index.html - Static HTML page accessible at http://localhost
  • C:/test/display/outbound - Contains Vue 3 project with favicon and index.html, along with the assets subfolder
  • C:/test/display/outbound/assets - Includes Vue 3 JS, CSS, and other necessary files

Edit 2 - Added screenshots of the DOM:

https://i.sstatic.net/0vJn6.png

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

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

Thank you in advance! If additional information is required, please do not hesitate to ask.

Answer №1

After some troubleshooting, I successfully resolved the issue by including

base: '/display/outbound/',

in my Vite.config.ts configuration file.

However, this solution has led to a new challenge that I have documented on Vue 3 Vite SPA Served on NGINX at Sub Root Location - Filter is Not a Function Error

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

Sequelize.js: Using the Model.build method will create a new empty object

I am currently working with Sequelize.js (version 4.38.0) in conjunction with Typescript (version 3.0.3). Additionally, I have installed the package @types/sequelize at version 4.27.25. The issue I am facing involves the inability to transpile the followi ...

The attribute 'completed' is not found in the 'EventTarget' interface

When using ion-refresher in Ionic Vue, I encountered an issue. The documentation suggests ending with 'event.target.complete()' but this results in the error: Property 'complete' does not exist on type 'EventTarget'. I am fol ...

Ways to verify a correct email address using ReactJS

I'm currently working on a project using React.js and Next.js. I'm encountering an issue with handling the Axios response in Next.js as it's displaying "[object Object]" instead of the actual response data. How can I properly handle the resp ...

Display previous messages in React JS chat when scrolling upwards

https://i.sstatic.net/mcJUp.png I am currently working on a chat application, as depicted in the image. Once the chat is initiated, it automatically scrolls down to display the most recent messages. My goal is to implement a feature where when a user sc ...

Ways to keep information hidden from users until they actively search for it

Currently, I have a custom filter search box that is functioning correctly. However, I want to modify it so that the data is hidden from the user until they perform a search. Can you provide any suggestions on how to achieve this? Below is the code I am u ...

discord.js: Imported array not displaying expected values

I've been facing an issue with accessing elements from an imported array. Even though the array is successfully imported, attempting to access its elements using [0] results in undefined. Here's how I exported the array in standList.js: exports. ...

A guide to accessing the currently hovered element on a Line Chart with Recharts

Just diving into this community and also new to ReactJS :( https://i.stack.imgur.com/k682Z.png I'm looking to create a tooltip that displays data only when hovering over the value 1 line. Unfortunately, the current tooltip is not behaving as expecte ...

Can you explain the distinction between object allocation using the '=&' operator and the Object.create() method?

I have been delving deep into JavaScript object operations. My question revolves around the difference between const me = Object.create(person); and const me = person;. Both of these operations provide a similar output as they reference the object to a new ...

Transmitting form information to a nested page within a div container

This is my fourth attempt to seek an answer to this question, as I've faced downvotes in previous attempts. So here we go again. I am trying to send data from a hidden input within a form using ajax. The value of the hidden input is generated by a php ...

Tips for using jQuery to create a delete functionality with a select element

I'm relatively new to utilizing jquery. I decided to tackle this project for enjoyment: http://jsbin.com/pevateli/2/ My goal is to allow users to input items, add them to a list, and then have the option to select and delete them by clicking on the t ...

Set the timezone of a Javascript Date to be zero

Is there a way to create a Javascript date without any specific timezone? When I try to do so in Javascript, it automatically sets it to GMT Pacific standard time. let newDate = new Date(new Date().getFullYear(), 0, 2, 0, 0, 0, 0) }, newDate: Sat Feb 01 2 ...

When trying to upload a file through input using WebDriver, the process gets stuck once the sendKeys

WebElement uploadInput = browser.findElementByXPath("[correct_identifier]"); uploadInput.sendKeys(elementPath); The script successfully initiates the file upload process, however, the custom JavaScript loading screen persists and fails to disappear as exp ...

"Troubleshooting: Why is my AngularJS ng-click not triggering the function

My custom directive fetches a navigation block from a webservice call. I am attempting to click on a navigation link that has an "ng-click" attribute set, which should call the specified function. However, the function is not being executed. Below is my r ...

Sending an axios GET request to an Express server works flawlessly on the initial attempt

I'm facing an issue while setting up a route to download videos in my Vue app, which is backed by an Express server. The first request sent to the backend works fine and the file is downloaded successfully. However, subsequent requests fail with a Net ...

The jQuery function throws an Error that is not caught by the surrounding try / catch block

Recently, I've been enhancing error handling in my JavaScript objects that heavily utilize jQuery. However, I've run into an issue where throwing a new Error from within a jQuery method is not caught by the surrounding catch statement. Instead, i ...

Implementing dynamic class bindings with Vue.js using v-for

I am currently using a v-for loop in Vue.js to create a list of items populated with data from an API. Here is an example of the items array: items: [ { foo: 'something', number: 60 }, { foo: 'anything', ...

Documentation for Lambda function within an object

Looking to properly document the sock and data variables using JSDoc in my code. var exec = { /** * @param {Number} sock * @param {String} data */ 1: (sock, data) => { console.log("GG"); }, 2: (sock, data ...

Issue with React application and nginx configuration causing components not to switch when using router functionality

I have encountered an issue while trying to deploy my React app using nginx. The problem I am facing is that when I change routes, for example to /about, the front end does not update and remains on the index page. Here is the configuration in sites-avai ...

Jest identifies active handles when executing synchronous scrypt operations in the crypto module of Node.js

During the execution of a unit test using the scryptSync function from the crypto package, I am encountering error messages and warnings that are unfamiliar to me. For instance, here is an example of a unit test I am running in Jest: it('Should match ...

Issue: Vue Storybook encounters compilation errors when using Pug components

Currently, I am in the process of integrating Storybook into my project that is coded using Pug. However, I encountered an issue where Storybook fails to compile when I create a story with a component written in Pug. Interestingly, if I switch the templa ...