Once the vue-cli has deployed to the server, the server's requested image path is now located in /dist/ folder

Issue with Image Loading:

While the demo successfully loads all resources and uploads images correctly, there is an issue where an extra /dist/ is being requested for image paths, resulting in a 404 error.

Demo Link:

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

Configuration of the Demo:

vue.config.js:

module.exports = {

  publicPath: process.env.NODE_ENV === "production" ? "/dist/" : "/",
  lintOnSave: false,
  devServer: {
    proxy: {
      "/demo": {
        target: "http://xx.xx.xxx.xxx",
        ws: true,
        changeOrigin: true
      }
    }

  }
};

router.js

export default new Router({
  mode: 'hash',
  base: "/dist/",
  routes: [...]
})

The intention is to place the dist folder in the server directory.

The goal is to eliminate the need for the /dist/ path and ensure that images load correctly.

During deployment, Vue-CLi automatically adds the /dist/ to image paths. While it works fine locally, the deployment on the server is appending more /dist/.

It seems like there was an error during server deployment. How can I rectify this?

Any assistance would be greatly appreciated!

Answer №1

You have the option to utilize the replace function in order to eliminate it from your URL:

var link = 'link/to/photo'

var editedLink = link.replace('/to','')

// Request(updatedLink, ...
console.log(editedLink)

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

Steps for aligning an image to the right using Bootstrap Vue

I'm currently learning Bootstrap Vue and I'm trying to align an image on the right using a b-card header. The challenge I'm facing is that when I add the image, it disrupts the perfect size of the template header, causing the image to show a ...

Fabric JS i-text cursor malfunctioning when loading JSON data

When I initially create a fabricjs i-text object in a new window, the cursor works perfectly. However, upon loading a saved JSON file, the cursor no longer functions as expected. I am utilizing the league_gothic font. Please refer to the image below showi ...

What could be causing Typed.js to not function properly in my situation?

Having an issue with typed.js not functioning properly. Here is the code snippet: <!-- jQuery (necessary for Bootstrap's JavaScript plugins) --> <script src="js/jquery-1.11.3.min.js"></script> <!-- Include all compiled plugins ...

Submit the form and additional information in a single AJAX request in Django

Seeking assistance with a straightforward task. The objective is to utilize AJAX POST to move data from a form along with additional information. The challenge lies in extracting this data from the form later on, as it constitutes an entire line. $(func ...

I keep encountering a parser error when making an AJAX call to retrieve JSON data. It seems to be caused by

here is a snippet of code I am working on $.ajax({ type: 'GET', url: "<%=request.getContextPath()%>/manageUsers.do", cache: false, data:{ "resultType": "json", "submit": $.i18n.prop('esadmin.manage.users ...

Tips for extracting text from a textarea while retaining newline characters:

When using jquery, my goal is to retrieve the text from a textarea element with new lines represented as \n instead of br tags. However, I encountered an issue where Firefox debugger does not display the \n or br characters when I select it and r ...

Struggling to retrieve information from session storage to pass along to a PHP class

Is there a way to fetch the email of the currently logged-in user from sessionStorage and send it to a PHP file? I have tried implementing this, but it seems to be not functioning properly. Could you assist me in resolving this issue? <?php $mongoCl ...

Avoid including package-lock.json file in GitHub contribution history

After the release of npm v5.0.0, utilizing npm packages automatically generates a package-lock.json file when running npm install. In my situation, my package-lock.json document is almost 10,000 lines long. Npm advises that this file should be committed: ...

incapable of utilizing the $q library and promises

I am trying to make use of the variable StatusASof within the inserthtml function in the following manner. App.controller("SS_Ctrl", function ($scope, $http, $location, $window, $sce, $q) { var ShiftDetails = []; function acquireMAStatusASof(Id) { ...

How can I use regular expressions to validate one-letter domain names?

I am in the process of developing a validation rule for my C# MVC Model using Regex. [RegularExpression(@"(\w[-._+\w]*\w@\w{1,}.\w{2,3})", ErrorMessage = "* Email Address: Please enter a valid Email Address.")] public virtual stri ...

Which is the better option for selecting DOM elements in a Vuejs 3 application: using raw js or jquery?

 I am currently working on developing an application using Node.js and Vue.js 3. One of the features I have implemented is a sidebar that dynamically fetches links from a routes file and displays them. The sidebar consists of a component that organize ...

Can you explain the significance of the "@" symbol prefix found in npm package names?

While reading through the Angular Component Router documentation, I came across an npm command that caught my attention: npm install @angular/router --save I'm puzzled by the meaning of @angular/router. Is this entire string a package name? If so, ...

Utilizing a combination of Mongo, Mongoose, Multer, and FS for deleting images

Looking at the code snippet below:- var Image = mongoose.model("Image", imageSchema); //Assuming all the configuration of packages are done app.delete("/element/:id", function(req, res) { Image.findByIdAndRemove(req.params.id, function(err) { if(e ...

How can we use PHP and jQuery to open a simple modal with data?

Here is a basic modal setup: <div id="info" style="display: none;"> <h3 class="title">User Information</h3> <table border="0" cellpadding="5" cellspacing="0"> <tr> <td width="50%" align="right ...

The Vuex state is being modified by an action, yet the associated computed property fails to react accordingly

I am facing an issue with fetching data from firebase using a store.js file that I have imported into the main.js. The problem is that the data does not display correctly when the page loads. However, when I check the console.log in mutations, it shows t ...

Storing a JWT refreshToken cookie in the response: Best practices

I'm currently in the process of using GraphQL to authenticate a user with JWT. After logging in, I receive a JSON response containing a token and an httponly cookie that stores the refresh token (Saleor-core is used on the server-side). After referri ...

Guide to setting up an object array in JavaScript with unique child elements and no duplicate values

I have an array that looks like this: sampleArray = ["x", "y", "z". "a.b", "a.b.c", "a.b.d", "a.e.f", "a.e.g"] However, I am aiming to transform it into the following structure, or something similar to it: newArray: [ { "x": [] }, ...

What is the best way to manage Page Refresh using Angular.js?

I recently followed the tutorial at http://scotch.io/bar-talk/setting-up-a-mean-stack-single-page-application This guide went over controllers and services using angular.js for a single-page application. However, when I try to directly access /pageName o ...

Issue with translating grid header names in Ag-Grid Vue using i18n without requiring a refresh after changing the language

Localization in my project is done using i18n, but I'm facing an issue where changing the language causes all page translations to display correctly except for the grid header names. The problem resolves itself when I refresh the page. How can I addre ...

What is the best way to retrieve a comprehensive outcome from a sql search utilizing php and consequently showcase it using javascript?

Need help with my PHP script that executes a query and returns multiple rows? Learn how to use json_encode in conjunction with JavaScript to fetch this data and display it in a table. This code snippet echoes two JSON encoded lines, each representing one ...