What’s the best way to prevent people to access the url of the template for our list detail pages?
For example:
I have a list detail page for more information about courses. Every course then has it’s own list detail page, like /course/example1 and /course/example2. But when someone directly goes to /course it shows the default template we’ve set up in Softr.
The only way I know how to handle this is with custom code. What this code does is looks at the URL and if it does not find a record ID, replaces the current page with one that has a record id for a default record. You could redirect anywhere, though.
<script>
if (!window.location.href.includes("/r/rec")) {
const urlParams = new URLSearchParams(window.location.search);
const recordId = urlParams.get('recordId');
if (!recordId) {
urlParams.set('recordId', "rec123")
window.history.replaceState({}, '', `${location.pathname}?${urlParams}`);
}
}
</script>
This is something that could be added into the platform by default. The reason it’s not yet added is that we feel sometimes the app builder might be just going into the page to check how it looks like Perhaps we should handle it similarly to 404 or 401. Still thinking