Approaches to build a public readonly application
I have to build a new feature for my application: readonly public access. So if user A has watched 2 movies, they can share a link with someone else and they will be able to see what 2 movies A has watched. They wont be able to perform authenticated actions ofc (leaving reviews etc).
How would I go about building something like this?
1 Reply
I would suggest 1 out of 2 options:
1. URL params
The link should be something like mysite.com/shared-movies?movies=id1,id2
Then create a custom page (shared-movies) which will be able to use those params to get the movie data or w/e from the db and show it to the user.
Or if you just need the movie names you might put just the names as params.
2. A similar approach, but instead of params you might have mysite.com/shared-movies/someid
here you would need to store the movies which should be shared in the DB with a special ID, in a separate table. This should happen when the user clicks share.
Then again, you will need to create a page that will read by that ID from the DB and display the data.
-----------------------------
I would go with approach 1. if you do not need to store any data or don't want to. As approach 2 will potentially create a lot of data in the DB that people might access once and never again - or you could have a timeout set for how long it lasts.
If you absolutely have to store it for w/e reason then go with 2.