Intevation / intelmq-fody

Web interface to IntelMQ
9 stars 3 forks source link

How to serve directly asked urls to subpages? #2

Closed bernhardreiter closed 7 years ago

bernhardreiter commented 8 years ago

vue-router does the routing internally, so when http://localhost:8080/tables is called, there is no request to the server. However if some user bookmarked this page and recalls it, the server will get the request should send the SPA (from index.html) and direct it to the subroute.

So we should have instructions how to serve this from a production server (after the run build step).

Observations:

Furthermore it is interesting to transfer parameters, e.g. /tables?displayItem=14 could be clarified along the way.

bernhardreiter commented 7 years ago

Another observation fody-0.2.0-dev served with yarn run dev sucessfully loads a subpage like http://localhost:8080/Contacts while a setup with Apache like outlined in the SetupUbuntuExample does not.

bernhardreiter commented 7 years ago

Technical solution idea is to configure the http server to route subpage requests to index.html as well. A test adding the following to checkticket.py works to enable /tickets:

@hug.get('/tickets', output=hug.output_format.file)
def root():
        return("/home/fody/www/index.html")

A simple variant would be to list all the subpages like this in hug.

A better solution maybe that the server will route everything that is does not know to index.html to load the single page. For this is may or may not be helpful to refactor checkticket.py to serve its contents below /api/.

bernhardreiter commented 7 years ago

Improved hug example in checkticket.py to server the subpages from fody's routes.js. Also updated intelmq-cp-mailgen release and routes.js with hints.