Add large file form fix patch
Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
@@ -4,11 +4,13 @@ USER root
|
||||
|
||||
ARG DOCKER_GID=975
|
||||
|
||||
RUN apk add docker docker-compose exiftool
|
||||
RUN apk add docker docker-compose exiftool patch
|
||||
RUN sed -i "s/^docker:x:.*$/docker:x:${DOCKER_GID}:node/" /etc/group
|
||||
|
||||
RUN npm install -g \
|
||||
sharp \
|
||||
exiftool-vendored
|
||||
|
||||
ADD large-file-form-fix.patch /tmp/large-file-form-fix.patch
|
||||
RUN patch /usr/local/lib/node_modules/n8n/templates/form-trigger.handlebars /tmp/large-file-form-fix.patch
|
||||
|
||||
USER node
|
||||
|
132
large-file-form-fix.patch
Normal file
132
large-file-form-fix.patch
Normal file
@@ -0,0 +1,132 @@
|
||||
diff --git a/packages/cli/templates/form-trigger.handlebars b/packages/cli/templates/form-trigger.handlebars
|
||||
index 08f6d2e29..1da88737f 100644
|
||||
--- a/packages/cli/templates/form-trigger.handlebars
|
||||
+++ b/packages/cli/templates/form-trigger.handlebars
|
||||
@@ -641,7 +641,7 @@
|
||||
});
|
||||
});
|
||||
|
||||
- form.addEventListener('submit', (e) => {
|
||||
+ form.addEventListener('submit', async (e) => {
|
||||
const valid = [];
|
||||
e.preventDefault();
|
||||
|
||||
@@ -690,67 +690,62 @@
|
||||
document.querySelector('#submit-btn').disabled = true;
|
||||
document.querySelector('#submit-btn').style.cursor = 'not-allowed';
|
||||
document.querySelector('#submit-btn span').style.display = 'inline-block';
|
||||
- fetch('', {
|
||||
+
|
||||
+ const response = await fetch('', {
|
||||
method: 'POST',
|
||||
body: formData,
|
||||
- })
|
||||
- .then(async function (response) {
|
||||
- const useResponseData = document.getElementById("useResponseData").value;
|
||||
-
|
||||
- if (useResponseData === "true") {
|
||||
- const text = await response.text();
|
||||
- let json;
|
||||
-
|
||||
- try{
|
||||
- json = JSON.parse(text);
|
||||
- } catch (e) {}
|
||||
-
|
||||
- if (json?.redirectURL) {
|
||||
- const url = json.redirectURL.includes("://") ? json.redirectURL : "https://" + json.redirectURL;
|
||||
- window.location.replace(url);
|
||||
- } else if (json?.formSubmittedText) {
|
||||
- form.style.display = 'none';
|
||||
- document.querySelector('#submitted-form').style.display = 'block';
|
||||
- document.querySelector('#submitted-content').textContent = json.formSubmittedText;
|
||||
- } else {
|
||||
- document.body.innerHTML = text;
|
||||
- }
|
||||
- return;
|
||||
- }
|
||||
+ });
|
||||
|
||||
- if (response.status === 200) {
|
||||
- if(response.redirected) {
|
||||
- window.location.replace(response.url);
|
||||
- return;
|
||||
- }
|
||||
- const redirectUrl = document.getElementById("redirectUrl");
|
||||
- if (redirectUrl) {
|
||||
- window.location.replace(redirectUrl.href);
|
||||
- } else {
|
||||
- form.style.display = 'none';
|
||||
- document.querySelector('#submitted-form').style.display = 'block';
|
||||
- }
|
||||
- } else {
|
||||
- form.style.display = 'none';
|
||||
- document.querySelector('#submitted-form').style.display = 'block';
|
||||
- document.querySelector('#submitted-header').textContent = 'Problem submitting response';
|
||||
- document.querySelector('#submitted-content').textContent =
|
||||
- 'Please try again or contact support if the problem persists';
|
||||
- }
|
||||
+ const useResponseData = document.getElementById("useResponseData").value;
|
||||
+
|
||||
+ if (useResponseData === "true") {
|
||||
+ const text = await response.text();
|
||||
+ let json;
|
||||
+
|
||||
+ try{
|
||||
+ json = JSON.parse(text);
|
||||
+ } catch (e) {}
|
||||
+
|
||||
+ if (json?.redirectURL) {
|
||||
+ const url = json.redirectURL.includes("://") ? json.redirectURL : "https://" + json.redirectURL;
|
||||
+ window.location.replace(url);
|
||||
+ } else if (json?.formSubmittedText) {
|
||||
+ form.style.display = 'none';
|
||||
+ document.querySelector('#submitted-form').style.display = 'block';
|
||||
+ document.querySelector('#submitted-content').textContent = json.formSubmittedText;
|
||||
+ } else {
|
||||
+ document.body.innerHTML = text;
|
||||
+ }
|
||||
+ return;
|
||||
+ }
|
||||
|
||||
+ if (response.status === 200) {
|
||||
+ if(response.redirected) {
|
||||
+ window.location.replace(response.url);
|
||||
return;
|
||||
- }).then(() => {
|
||||
- window.addEventListener('storage', function(event) {
|
||||
- if (event.key === 'n8n_redirect_to_next_form_test_page' && event.newValue) {
|
||||
- const newUrl = event.newValue;
|
||||
- localStorage.removeItem('n8n_redirect_to_next_form_test_page');
|
||||
- window.location.replace(newUrl);
|
||||
- }
|
||||
- });
|
||||
- })
|
||||
- .catch(function (error) {
|
||||
- console.error('Error:', error);
|
||||
- });
|
||||
+ }
|
||||
+ const redirectUrl = document.getElementById("redirectUrl");
|
||||
+ if (redirectUrl) {
|
||||
+ window.location.replace(redirectUrl.href);
|
||||
+ } else {
|
||||
+ form.style.display = 'none';
|
||||
+ document.querySelector('#submitted-form').style.display = 'block';
|
||||
+ }
|
||||
+ } else {
|
||||
+ form.style.display = 'none';
|
||||
+ document.querySelector('#submitted-form').style.display = 'block';
|
||||
+ document.querySelector('#submitted-header').textContent = 'Problem submitting response';
|
||||
+ document.querySelector('#submitted-content').textContent =
|
||||
+ 'Please try again or contact support if the problem persists';
|
||||
+ }
|
||||
+
|
||||
+ window.addEventListener('storage', function(event) {
|
||||
+ if (event.key === 'n8n_redirect_to_next_form_test_page' && event.newValue) {
|
||||
+ const newUrl = event.newValue;
|
||||
+ localStorage.removeItem('n8n_redirect_to_next_form_test_page');
|
||||
+ window.location.replace(newUrl);
|
||||
+ }
|
||||
+ });
|
||||
|
||||
const isWaitingForm = window.location.href.includes('form-waiting');
|
||||
if(isWaitingForm) {
|
Reference in New Issue
Block a user