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

PREVIOUS NEXT
Code Example
Javascript :: or operator in javascript 
Javascript :: round number 2 decimals javascript 
Javascript :: express server 
Javascript :: import image as component react 
Javascript :: import bootstrap in react 
Javascript :: nodejs emit event from class 
Javascript :: js isset variable 
Javascript :: js send file as form input 
Javascript :: sequelize sqlite example 
Javascript :: get first 10 characters of string javascript 
Javascript :: js tolowercase 
Javascript :: draw on canvas from video element js 
Javascript :: .net mvc javascript function call link 
Javascript :: upload image react 
Javascript :: how to round numbers in javscript 
Javascript :: vue 3 cdn example 
Javascript :: radio button group get value javascript 
Javascript :: react google map 
Javascript :: js join 
Javascript :: what is currying in javascript 
Javascript :: node js server 
Javascript :: update object in array if id exists else append javascript 
Javascript :: angular jspdf 
Javascript :: javascript remove array element 
Javascript :: copy to clipboard reatjs 
Javascript :: Pass object to query on Router.push NextJs 
Javascript :: merge objects js 
Javascript :: convert a new date standard to a yyy-mm-dd format in javascript 
Javascript :: how make date object in jquery from custom date 
Javascript :: network display react native 
ADD CONTENT
Topic
Content
Source link
Name
6+4 =