I have vue.js client code with flask server backend code. If I click on various links in my browser app, the links get (using axios) data from backend and render the data properly e.g, if I have a router-link to http://localhost:5000/books. But if I enter this same url directly in the browsers address bar, I get back the raw json from server (i.e, it does not go via vue.js to render in my html table). I am using mode: "history" in my router.js file.
I have browsed other related queries on SO, but still unable to grasp what exactly I need to do to make this work (they all seem to recommend using history mode, which I am. In other cases, they say I need to configure flask to handle such requests .. but do not clearly say what I need to do to handle such requests). Any one have clear idea about this ?
Router.js File
==============================
export default new Router({
routes: [
{ path: "/", name: "home", component: Home },
{ path: "/about", name: "about", component: About },
{ path: "/ping", name: "Ping", component: Ping },
{ path: "/books", name: "Books", component: Books },
{ path: "/*", name: "NotFound", component: NotFound } /*Catch All*/
],
mode: "history"
});
Below is excerpt from my flask app.
Flask App.py
============
from flask import Flask, jsonify, request, send_from_directory, render_template
from flask_cors import CORS
# instantiate the app
app = Flask(__name__, static_url_path='', static_folder='static')
app.config.from_object(__name__)
CORS(app)
...
...
@app.route('/books', methods=['GET'])
def GetAllBooks():
...
...
@app.route('/')
@app.route('/index.html')
def index():
return app.send_static_file('index.html')
@app.route('/<path:path>')
def static_file(path):
return app.send_static_file(path)
if __name__ == '__main__':
app.run()
Below is my table rendered when I click on "Books" link.
Below is the data returned if I enter the url directly in the address bar.

