Error 404 encountered while trying to access a website with parameters using Vue.js

Currently, I am in the process of building a website using VueJS and recently discovered how to use url parameters. Everything was working perfectly on my local machine - I could easily navigate to different pages by including parameters in the URL.

For example, I would type localhost:8080 to access the index site and then enter localhost:8080/param1/param2 to visit another page, all without any issues. I even noticed that typing localhost:8080/param1/param2 directly into the browser worked seamlessly as well, no need to first go to the index page.

However, once I built and uploaded the website to my hosting provider, I encountered a problem. I could no longer input the URL with parameters directly; it only worked when navigating from the index page.

An error message popped up:

404 Error

Being relatively inexperienced with routing and web hosting, I tried researching for a solution online but came up empty-handed. Any assistance you could provide would be greatly appreciated.

Additional details based on comments I've received:

About my web host: I have access to Plesk where I can manage my settings. Within the platform, I see "Apache & nginx" settings that appear like this:

Apache Settings

nginx Settings

Answer №1

One reason for this situation is that Single Page Applications (SPAs) do not utilize different HTML pages for various URLs like traditional websites. Therefore, you will need to either direct all requests to the index.html page in your server settings or configure the history property using history: createWebHashHistory().

Please let me know if this solution resolves the issue.

P.S: Unfortunately, I am not familiar with configuring these settings in Apache or Nginx.

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

Select from a variety of backgrounds using the dropdown menu on the site

I seem to be struggling with javascript and php, but I know that in order to make this function properly, I need to utilize both languages. My goal is to set up a "select box" featuring 4 different images. There will be a default image displayed, but user ...

Vue - employing a function to combine the values of two user inputs and store the result in the data property

Currently experimenting with a component in Vue. I am attempting to implement two input boxes where users can enter integers and save them as data properties using buttons. The goal is then to add these saved integers together by clicking another button, ...

Steps for displaying a bootstrap modal in alignment with the triggering button's position

Recently diving into the world of bootstrap and AngularJs has been quite the learning experience for me. One challenge I encountered was trying to implement a bootstrap modal dialog box to show additional details within a table column. My goal was to hav ...

Learn how to mock asynchronous calls in JavaScript unit testing using Jest

I recently transitioned from Java to TypeScript and am trying to find the equivalent of java junit(Mockito) in TypeScript. In junit, we can define the behavior of dependencies and return responses based on test case demands. Is there a similar way to do t ...

Modifying an element in an array while preserving its original position

Currently, I am working on updating the state based on new information passed through response.payload. Here is my existing code snippet: if(response.events.includes('databases.*.collections.*.documents.*.update')) { setMemos(prevState => pre ...

Prevent the use of unnecessary object properties

Currently, my project involves using Typescript and React in conjunction with Material-UI. Specifically, I am utilizing Material-UI's styling solution, which implements CSS in JS methodology in a Hook-like manner as outlined in their documentation: co ...

Having difficulty resolving issues with the chat box (div) scroll bar staying fixed at the bottom

I am currently working on a chat application and I am facing an issue with fixing the scroll bar at the bottom of a div when loading my PHP file. I have already written a script to achieve this, but despite accessing it using CSS Id, I am having trouble ge ...

Having difficulty capturing an error related to an invalid form body in discord.js

I built a command to send an embed based on JSON data, and it's working well for the most part. When I input the data correctly, the bot sends it to the channel as expected. However, if someone tries to insert text in a link section, it crashes the b ...

React modal not triggered on click event

As a newcomer to react, I am exploring a modal component import React, { useState, useEffect } from 'react'; import { Modal, Button } from "react-bootstrap"; function TaskModal(props) { return ( <Modal show={pro ...

Tips for retrieving the value sent via an AJAX $.post request in a PHP file

Here is an example of my Ajax call: var keyword = $('#keyword').value; $.post("ajax.php?for=result", {suggest: "keyword="+keyword}, function(result){ $("#search_result").html(result); }); In the PHP file, I am trying to ret ...

Stock Chart that resembles the functionality of Google's popular line chart feature

Can anyone recommend a Javascript or SVG chart library that has a style similar to a Google Chart? I have been searching without much luck and would appreciate some guidance on how to achieve a similar look. I've looked into the Google Visualization ...

Having trouble with AES decryption on my nodeJS/ExpressJS server backend

Looking to decipher data post retrieval from mongoDb. The retrieved data comprises encrypted and unencrypted sections. app.get("/receive", async (req, res) => { try { const data = await UploadData.find(); const decryptedData = data. ...

Having trouble updating the input value in AngularJS?

As I venture into customizing an AngularJS tutorial on a Saturn Quiz, I am transforming it from multiple choice to a fill-in-the-blank quiz. The challenge I face is that the first answer registers as correct or incorrect, but subsequent questions always s ...

Acquiring the underlying code of websites within the local network

In the tool I am creating, it takes a URL as a parameter and retrieves the source code from that URL for analysis. The tool will be hosted on our domain, with the capability of analyzing web pages of sites within our internal network domain. Here is the Jq ...

Next.js encountered a surprising conclusion to the JSON input

After retrieving data from /api/notes/1, the following JSON object is received: { "id":1, "author":1, "title":"First Note", "excerpt":"Just a note, blah blah blah", "body":"First no ...

Increase the size of a centered image within a table

Lately, I've felt like my mind is starting to unravel. Here's the issue at hand: I've been attempting to resize an image within a table cell so that it spans the full width of the cell. Strangely enough, this seems to be harder than anticip ...

When typing in the textarea, pressing the return key to create a line break does not function as expected

Whenever I hit the return key to create a new line in my post, it seems to automatically ignore it. For example, if I type 'a' press 'return' and then 'b', it displays 'ab' instead of 'a b'. How can I fi ...

I keep receiving a 400 (Bad Request) error when trying to delete with my REST API

I've successfully created an API and have managed to make POST and GET requests work flawlessly. However, I'm facing some trouble with the DELETE request. Every time I try to execute it, I encounter a 'DELETE http://localhost:3000/api 400 (B ...

Unable to pass value through form submission

Having some trouble displaying data from an API on my HTML page. The function works fine when I run it in the console. <body> <div> <form> <input type="text" id="search" placeholder="Enter person& ...

Getting a variable from an ajax call and using it in a Pug template

Currently, I am experimenting with Express and Pug to learn some new concepts. Upon making a request to a website, I received some dynamic information stored in an array. However, I am facing challenges when trying to iterate over this array using Pug. The ...