Skip to content

Why does vue.js report 404 route in production, but not development? #2854

@atrueresistance

Description

@atrueresistance

Version

3.0.3

Reproduction link

https://stackoverflow.com/questions/57013982/why-does-vue-js-report-404-route-in-production-but-not-development

Steps to reproduce

Running npm run serve I can visit auth/login, but after npm run build the server returns a 404 on auth/login.

I get a 404 when going to https://example.com/auth/login but navigating to https://example.com/address-records works just fine. It seems as if only something that is more than a single / deep returns a 404.

Here is the router code

let router = new Router({
  mode: "history",
  base: process.env.BASE_URL,
  routes: [
    {
      path: "/",
      name: "home",
      component: Home
    },
    {
      path: "/auth/login",
      name: "Login",
      component: Login
    },
    {
      path: "/address-records",
      name: "Address",
      component: Address
    }
  ]
});

Is there something special I need to be doing with Nginx? I have it setup with similar searched questions.

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

 location ~* \.(?:ico|css|js|gif|jpe?g|png)$ {
         # Some basic cache-control for static files to be sent to the browser
         expires max;
         add_header Pragma public;
         add_header Cache-Control "public, must-revalidate, proxy-revalidate";
  }

What is expected?

200 status code from auth/login in production

What is actually happening?

404 status code from auth/login in production

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions