nuxtjs-drupal-ce
Advanced tools
Comparing version
@@ -19,3 +19,3 @@ import * as _nuxt_schema from '@nuxt/schema'; | ||
serverLogLevel?: boolean | 'info' | 'error'; | ||
disableFormHandler?: boolean; | ||
disableFormHandler?: boolean | string[]; | ||
} | ||
@@ -22,0 +22,0 @@ declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>; |
@@ -7,3 +7,3 @@ { | ||
}, | ||
"version": "2.2.6", | ||
"version": "2.3.0", | ||
"builder": { | ||
@@ -10,0 +10,0 @@ "@nuxt/module-builder": "0.8.4", |
@@ -170,9 +170,7 @@ import { defu } from "defu"; | ||
if (typeof customElements === "string") { | ||
return defineComponent({ | ||
setup() { | ||
return () => h("div", { | ||
innerHTML: customElements | ||
}); | ||
} | ||
}); | ||
const component = resolveCustomElement("drupal-markup"); | ||
if (component) { | ||
return h(component, { content: customElements }); | ||
} | ||
return h("div", customElements); | ||
} | ||
@@ -185,10 +183,6 @@ if (Object.keys(customElements).length === 0) { | ||
setup() { | ||
return () => h( | ||
"div", | ||
{}, | ||
customElements.map((element) => { | ||
const rendered = renderCustomElements(element); | ||
return rendered ? h(rendered) : null; | ||
}) | ||
); | ||
return () => customElements.map((element) => { | ||
const rendered = renderCustomElements(element); | ||
return rendered ? h(rendered) : null; | ||
}); | ||
} | ||
@@ -195,0 +189,0 @@ }); |
@@ -5,5 +5,22 @@ import { defineEventHandler, readFormData } from "h3"; | ||
export default defineEventHandler(async (event) => { | ||
const { disableFormHandler } = useRuntimeConfig().drupalCe; | ||
const { ceApiEndpoint } = useRuntimeConfig().public.drupalCe; | ||
if (event.node.req.method === "POST") { | ||
if (event.req.headers["x-form-processed"]) { | ||
const routesToBypass = Array.isArray(disableFormHandler) ? disableFormHandler : []; | ||
if (routesToBypass.length) { | ||
const currentPath = event.node.req.url?.split("?")[0] || ""; | ||
const shouldBypass = routesToBypass.some((route) => { | ||
const routeFormats = [ | ||
route, | ||
"/api/drupal-ce" + route, | ||
ceApiEndpoint + route | ||
]; | ||
return routeFormats.some((format) => format === currentPath); | ||
}); | ||
if (shouldBypass) { | ||
return; | ||
} | ||
} | ||
const contentType = event.node.req.headers["content-type"] || ""; | ||
if (!contentType.includes("multipart/form-data") && !contentType.includes("application/x-www-form-urlencoded") || event.node.req.headers["x-form-processed"]) { | ||
return; | ||
@@ -10,0 +27,0 @@ } |
{ | ||
"name": "nuxtjs-drupal-ce", | ||
"version": "2.2.6", | ||
"version": "2.3.0", | ||
"license": "MIT", | ||
@@ -11,8 +11,6 @@ "bin": { | ||
".": { | ||
"import": "./dist/module.mjs", | ||
"require": "./dist/module.cjs" | ||
"import": "./dist/module.mjs" | ||
} | ||
}, | ||
"main": "./dist/module.cjs", | ||
"types": "./dist/types.d.ts", | ||
"main": "./dist/module.mjs", | ||
"files": [ | ||
@@ -38,17 +36,18 @@ "dist", | ||
"devDependencies": { | ||
"@nuxt/eslint": "^1.2.0", | ||
"@nuxt/eslint-config": "^1.2.0", | ||
"@nuxt/kit": "^3.16.1", | ||
"@nuxt/module-builder": "^0.8.4", | ||
"@nuxt/schema": "^3.16.1", | ||
"@nuxt/eslint": "^1.3.0", | ||
"@nuxt/eslint-config": "^1.3.0", | ||
"@nuxt/kit": "^3.16.2", | ||
"@nuxt/module-builder": "^1.0.1", | ||
"@nuxt/schema": "^3.16.2", | ||
"@nuxt/test-utils": "^3.17.2", | ||
"@nuxtjs/i18n": "^9.3.3", | ||
"@nuxtjs/i18n": "^9.5.3", | ||
"@playwright/test": "^1.52.0", | ||
"@vue/test-utils": "^2.4.6", | ||
"eslint": "^9.22.0", | ||
"eslint": "^9.25.1", | ||
"happy-dom": "^15.11.7", | ||
"nuxt": "^3.16.1", | ||
"playwright-core": "^1.51.1", | ||
"typescript": "^5.8.2", | ||
"vitest": "^1.6.1" | ||
"nuxt": "^3.16.2", | ||
"playwright-core": "^1.52.0", | ||
"typescript": "^5.8.3", | ||
"vitest": "^3.1.2" | ||
} | ||
} |
@@ -159,2 +159,32 @@ # nuxtjs-drupal-ce - Nuxt Drupal Custom Elements Connector | ||
## Form handler middleware | ||
The form handler middleware is used to process Drupal form submissions by forwarding form-POST | ||
requests to Drupal and rendering the response as usual. This option allows you to bypass this | ||
middleware for certain routes or to disable it globally. | ||
### Route level | ||
To bypass the form handler middleware for certain routes, you can use the `disableFormHandler` option with an array of routes: | ||
```js | ||
export default defineNuxtConfig({ | ||
drupalCe: { | ||
disableFormHandler: ['/custom-form'], | ||
}, | ||
}) | ||
``` | ||
### Global level | ||
To disable the form handler middleware globally, you can use the `disableFormHandler` option with `true`: | ||
```js | ||
export default defineNuxtConfig({ | ||
drupalCe: { | ||
disableFormHandler: true, | ||
}, | ||
}) | ||
``` | ||
## Deprecated options | ||
@@ -161,0 +191,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
51696
3.6%576
2.13%285
11.76%15
7.14%