Fix form show page - clean code

This commit is contained in:
Julien Nahum 2024-01-16 11:46:03 +01:00
parent b25bc8bca8
commit 49088e62bc
3 changed files with 9 additions and 15 deletions

5
client/lib/utils.js vendored
View File

@ -77,10 +77,5 @@ export const customDomainUsed = function() {
const appDomain = getDomain(config.public.appUrl)
const host = getHost()
console.debug('customDomainUsed', {
'appDomain': appDomain,
'host': host,
'customDomain': host !== appDomain && getDomain(host) !== appDomain
})
return host !== appDomain && getDomain(host) !== appDomain
}

View File

@ -21,7 +21,7 @@
<div v-if="!formLoading && !form">
<h1 class="mt-6" v-text="'Whoops'"/>
<p class="mt-6">
Unfortunately we could not find this form. It may have been deleted by it's author.
Unfortunately we could not find this form. It may have been deleted.
</p>
<p class="mb-10 mt-4">
<router-link :to="{name:'index'}">
@ -115,25 +115,25 @@ await loadForm(slug)
useOpnSeoMeta({
title: () => {
if (form && form.value.is_pro && form.value.seo_meta.page_title) {
if (form && form.value?.is_pro && form.value.seo_meta.page_title) {
return form.value.seo_meta.page_title
}
return form.value ? form.value.title : 'Create beautiful forms'
},
description () {
if (form && form.value.is_pro && form.value.seo_meta.page_description) {
description: () => {
if (form && form.value?.is_pro && form.value.seo_meta.page_description) {
return form.value.seo_meta.page_description
}
return (form && form.value.description) ? form.value.description.substring(0, 160) : null
return (form && form.value?.description) ? form.value?.description.substring(0, 160) : null
},
ogImage () {
if (form && form.value.is_pro && form.value.seo_meta.page_thumbnail) {
ogImage: () => {
if (form && form.value?.is_pro && form.value.seo_meta.page_thumbnail) {
return form.value.seo_meta.page_thumbnail
}
return (form && form.value.cover_picture) ? form.value.cover_picture : null
return (form && form.value?.cover_picture) ? form.value?.cover_picture : null
},
robots: () => {
return (form && form.value.can_be_indexed) ? null : 'noindex, nofollow'
return (form && form.value?.can_be_indexed) ? null : 'noindex, nofollow'
}
})
useHead({

View File

@ -3,7 +3,6 @@ export default defineNitroPlugin(nitroApp => {
const routePath = event.node?.req?.url || event.node?.req?.originalUrl
// const routePath= event.context.params._
if (routePath && !routePath.startsWith('/forms/')) {
console.error('Not a form, setting X-Frame-Options', routePath)
// Only allow embedding of forms
response.headers['X-Frame-Options'] = 'sameorigin'
}