Adonis 5 and Vue encountering the error message 'E_ROUTE_NOT_FOUND'

I am currently working on a project using Adonis v5 as the backend and Vue 2 as the frontend. I have encountered an issue where, after building the Vue frontend into the public Adonis folder, accessing a specific route directly in the browser results in an E_ROUTE_NOT_FOUND error from Adonis.

It seems that Adonis is attempting to search for the route within its own router instead of the Vue router, despite Adonis being configured to serve static files and the initial frontend page working correctly:

Vue router.js:

Vue.use(VueRouter);
const routes = [
{
 path: "/",
 redirect: { name: "acceso" },
},
{
 path: "/acceso",
 name: "acceso",
 component: SignupView,
 meta: { guestAllow: true },
}];

const router = new VueRouter({
 mode: "history",
 routes,
});

Adonis routes.ts (with prefix that should not affect this issue):

Route.group(() => {
  Route.group(() => {
    Route.post("register", "AuthController.register");
    Route.post("login", "AuthController.login");
  }).prefix("auth");
  Route.group(() => {
    Route.get("logs", "LogsController.index");
  }).middleware("auth:api");
}).prefix("/api");

Adonis static.ts:

import { AssetsConfig } from '@ioc:Adonis/Core/Static'
const staticConfig: AssetsConfig = {
 enabled: true,
 dotFiles: 'ignore',
 etag: true,
 lastModified: true,
 maxAge: 0,
 immutable: false,
}

When entering localhost:3333 in the browser, it redirects to /access successfully

However, upon refreshing the page or manually browsing the same route, the error occurs

If you have any insights or ideas on what could be causing this issue, I would greatly appreciate your input. Thank you for your time.

Answer №1

After browsing through some other projects online, I discovered that using mode: "history" in vue-router leads to an error.

Therefore, I decided to comment out this line and now I am able to refresh the page without encountering the E_ROUTE_NOT_FOUND error.

Here is a snippet from my frontend Vue router.js file:

const router = new Router({
  //mode: "history",
  routes,
});

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

Conceal the Angular alert message automatically after a specified number of seconds or when the page

I recently started working with Angular and managed to implement an alert message for password reset requests in our app: Usermodel: .service('userModel', ['$q', '$http', 'authorizedTracker', function($q, $http, au ...

Tips for preventing tiny separation lines from appearing above and below unordered list elements

I am attempting to utilize twitter bootstrap to create a select-option style list. How can I eliminate the thin separation lines above and below the list of items? Refer to the screenshot: Below is the visible code snippet. It would be best to view the j ...

Press the 'enter' button to post your tweet with Greasemonkey

I am working on a Greasemonkey script that will automatically submit a tweet when the user presses the 'enter' key. The script works perfectly on a basic HTML page with some help from tips I found on this website. However, when I attempt to use t ...

Tips for extracting data from a state-based object store in React?

Whenever I attempt to execute a PUT call, I fetch the data by id and save it in a state named "getData". While I am able to filter and map over this data, I face issues when trying to extract individual values. For instance, accessing getData.firstName res ...

I possess a primary menu with several submenus, yet I am encountering difficulty accessing the submenus. My goal is to efficiently navigate and access the appropriate submenu within the main menu

I am facing an issue with my CSS where the sub menu is currently showing from the left side, but I would like it to slide up and down instead. .outer { width: 100%; text-align: center; background-color: Gray; padding-top: 20px; bord ...

Utilize a Vue2 component that has been defined in the same file within another

I'm attempting to establish a reference from one locally defined vue2 Component to another in the following manner: new Vue({ el: '#app', components: { 'foo': {template: '<p>Foo</p>'}, 'bar&ap ...

How can I clear my object so that new Dates() can be added to my calendar?

I am working on updating my program to seamlessly replace old JSON data from a holidays API with new data as soon as it is received. Initially, I attempted to declare the array as empty at the start, but this approach did not yield the desired results. Si ...

Tips for determining the duration between the Monday of last week and the Sunday of last week

Can anyone help me figure out how to retrieve the dates from last week's Monday to last week's Sunday using JavaScript? I've searched through various sources with no luck. Hoping someone here can provide some guidance. ...

Insert well-formed JSON into an HTML element

I'm facing a challenge while trying to dynamically embed a valid JSON array into HTML. The issue arises when the text contains special characters like quotes, apostrophes, or others that require escaping. Let me illustrate the problem with an example ...

Conceal rows in a table that are not selected using Jquery when the table has been loaded from a given URL

Below is the HTML code for an user search input field and the results table: <div class="input-group"> <input type="text" id="q" class="form-control" placeholder="Search for User"> <span class="input-group-btn"> ...

What is the process for modifying the logfile path in phantomjs using selenium?

Is there a way to modify the default --webdriver-logfile parameter that selenium passes to phantomjs when using them together? This is the line in the selenium log: 11:06:06.960 INFO - arguments: [--webdriver=14380, --webdriver-logfile=<ROOT PATH DELE ...

Troubleshooting jQuery's issue with dynamically adding input fields

I came across a tutorial (which I tweaked slightly) on this website: code In JSFiddle, everything works perfectly fine with the code. However, when I implemented it on my actual page, it's not functioning as expected. I've been trying to trouble ...

The JavaScript code is not executing properly within the HTML document

I am trying to execute a function from my JavaScript file in my HTML page. Here is the code snippet: index.html <!DOCTYPE html> <html><body> <h2>Web1</h2> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jq ...

Getting a string from JSON using Javascript

I am trying to retrieve a specific skill from a variable: const skillsData = [ { name: "React", value: 390 }, { name: "CSS", value: 1200 }, { name: "JavsScript", value: 540 }, { name: "HTML", value: 1900 }, ...

How can I effectively utilize executeScript in Selenium and webdriver.io?

I'm currently working on testing a basic form using Selenium, WebDriver.io, and Node.js (with Mocha). Here is a snippet of the code I have: var webdriverio = require('webdriverio'); var expect = require('expect'); describe(' ...

Combining Vue-Test-Utils with TypeScript typings for wrapper.vm

So, I ran into an interesting situation. Has anyone ever worked with typescript + vue-test-utils and attempted to change a value for testing purposes like this: wrapper.vm.aCoolRefValueToManipulate = 'something much cooler'? I gave it a shot, a ...

JavaScript code that triggers a function when the mouse is moved over a description box on a

As a beginner in the field of Computer Science, I recently embarked on a project to create a website for sharing science articles with students. The goal is to spark curiosity and interest in science through this platform. One key feature I wanted to inclu ...

Unlock the secrets of filtering a JSON array object with nested SQL Query-like precision using ES6 syntax for maximum efficiency

As someone new to ES6 syntax, I could use some assistance with this task. I have a JSON array structured like so: var data = [{ "recordid": 1, "recordidclass": "Parent Class", "relatedrecid": 2, "relatedrecclass": "Child Class2" }, { ...

Why is it that I cannot use the .get method on JSON data? And what is the best way to convert JSON into a map?

I'm currently in the process of creating a test for a function that accepts a map as an argument, Under normal circumstances when the code is executed outside of a test, the parameter would appear like this (when calling toString): Map { "id": "jobs ...

Difficulty arising from the final column of average sums - Information extracted from JSON using Angular JS

I am facing a problem with calculating the average total. I need to determine the average sum using a specific formula, but the code provided does not calculate the last column of Average. I am looking for a desired result and would appreciate any assistan ...