Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

on refresh page vue.js application return 404



I think you are missing that SPA is not server side rendering. At least for the majority. So, when you access /anything your web server won't redirect it to index.html. However, if you click on any vuejs router link, it will work due to the fact that the javascript got in action, but not the server side.

To solve this, use .htaccess and redirect all requests to index.html like so

<ifModule mod_rewrite.c>
    RewriteEngine On
  RewriteBase /
  RewriteRule ^index.html$ - [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . /index.html [L]
</ifModule>
Hope it helps someone!
Comment

Vue JS Production mode refresh causing 404 error

url:  https://next.router.vuejs.org/api/#history

createRouter({
  history: createWebHashHistory(),
  // other options...
})
Comment

PREVIOUS NEXT
Code Example
Javascript :: The element.InnerHTML Property 
Javascript :: select parent of elemt 
Javascript :: get user input node js console 
Javascript :: getting te value of select multiple value 
Javascript :: how to make bootstrap navbar to change on scroll 
Javascript :: puppeteer event element change 
Javascript :: react eslint 
Javascript :: axios node js 
Javascript :: Javascript - find the largest 
Javascript :: how to insert with variables from js to mysql 
Javascript :: express.js hello world 
Javascript :: remove trailing zeros javascript 
Javascript :: angular http get status code 
Javascript :: path module js 
Javascript :: disable URL encoder javascript 
Javascript :: javascript caeser cipher 
Javascript :: import tippy react 
Javascript :: js setinterval vs settimeout 
Javascript :: javascript regex match character from a set of characters 
Javascript :: angular tab change smooth transition 
Javascript :: jquery.mask.js 
Javascript :: npm ERR! Error: connect ECONNREFUSED 
Javascript :: enzynme not support react 17 
Javascript :: how to make button in react js 
Javascript :: js or 
Javascript :: angular how to run code every time you route 
Javascript :: add val in data-id jquery 
Javascript :: add background image react native 
Javascript :: remove duplicates from array javascript 
Javascript :: cypress test only one file 
ADD CONTENT
Topic
Content
Source link
Name
5+6 =