I have a web application in the following infrastructure:
A server hosts a server side endpoint which accepts GET or POST requests. If the endpoint is got, a form is returned which allows the user to submit data to a MySQL database of his own choice, by supplying the credentials in the form, which is posted to the same endpoint. The page also returns the result of the last operation along the form using the POST-redirect-GET idiom, setting a cookie in between. If the endpoint is posted, the server writes the MySQL database requested by the user using the data and credentials received in the form.
There is currently some JavaScript but it is for enhancing the UI only and immaterial to the infrastructure.
I'd like to improve the web application such that:
- It can still work without JavaScript, by using server-side scripting mentioned above.
- However, if it is run on a modern browser, the whole logic should be done by client side script, in the sense that when the form is submitted, the client actually writes to the MySQL database itself and shows the result without involving the web server. In this case, it can be installed as a Progressive Web App and run offline.
Is the above possible with the same source code containing the business logic in accessing the database, which in the build process, produces both server side and client side JavaScript? Can existing SSR frameworks do the above with Vue?