Fix URL for embeddable middleware

This commit is contained in:
Julien Nahum 2024-01-12 11:44:59 +01:00
parent 5d78fc67c6
commit 4115b44f1d
1 changed files with 3 additions and 2 deletions

View File

@ -1,7 +1,8 @@
export default defineNitroPlugin(nitroApp => {
nitroApp.hooks.hook('render:response', (response, { event }) => {
const routePath= event.context.params._
if (!routePath.startsWith('forms/')) {
const routePath = event.node?.req?.url || event.node?.req?.originalUrl
// const routePath= event.context.params._
if (routePath && !routePath.startsWith('forms/')) {
// Only allow embedding of forms
response.headers['X-Frame-Options'] = 'sameorigin'
}