Getting 405 error on form redirect

I have two embed iframe forms on two different plasmic pages. The form system pass url params from one form to another.
Form1 redirects to Form2 https://hairpin.ai/forms/client-survey?userEmail={userEmail}
I get a 405 error
I reload the page and it works perfectly…
What can I do to bypass this 405?

I tried setting up the URL parameters in my plasmic Page data.
I tried a sloppy hack js window.location.reload()
I must be missing something… I’m stuck

Screenshot 2023-07-21 at 7.58.31 PM.png

Screenshot 2023-07-21 at 8.15.14 PM.png

Hi, sorry I don’t understand what is the situation and what is the issue. I tried inserting an iframe with that URL and it seems to work, so I’m guessing that’s not the issue.

Also, this describes how to create dynamic pages: https://docs.plasmic.app/learn/dynamic-pages/

@yang
-Please add a test email to this form: https://hairpin.ai/forms/contact
-Go to the end, click Submit
-You will be redirected to the next form with a 405 error. (look at url, you’ll se your ?userEmail)
-Refresh the page (it works)

What is wrong in my plasmic settings?

Sorry, I think I’m still confused - I just went directly to the jotform URL, submitted the form and still got 405. Is the question related to Plasmic?

https://form.jotform.com/231924387634160?isIframeEmbed=1

Yes, because you got redirected to https://hairpin.ai/forms/client-survey?userEmail=yourtest@email.com

the first form is loading fine. it’s the redirect that is not being accepted by plasmic it seems like

Right, how was this Next.js application created/setup/hosted?

by plasmic, no self hosting on this one

From Jotform I redirect to the following:

It seems to be working here like this:

You meed to submit the first form/contact

https://hairpin.ai/forms/contact

Hmm, why is the jotform then trying to POST to this URL?

I don’t know… Do you have time to do a share screen? or I can send you a screen recording

Sorry I don’t, but it should be something in the jotform settings - you aren’t going to be able to POST to a Next.js app like that unless you’ve defined your own API handlers in your own self hosted codebase

Why is it working when you reload then?

@yang

Because that’s sending a normal get request

    <iframe
      id="JotFormIFrame-231924387634160"
      title="Website Questionnaire Form"
      onload="window.parent.scrollTo(0,0)"
      allowtransparency="true"
      allowfullscreen="true"
      allow="geolocation; microphone; camera"
      src="<https://form.jotform.com/231924387634160>"
      frameborder="0"
      style="width:100%;height:100%;border:none;"
      scrolling="no"
    >
    </iframe>
    <script type="text/javascript">
    var ifr = document.getElementById("JotFormIFrame-231924387634160");
    if (ifr) {
      var src = ifr.src;
      var iframeParams = [];
      if (window.location.href && window.location.href.indexOf("?") > -1) {
        iframeParams = iframeParams.concat(window.location.href.substr(window.location.href.indexOf("?") + 1).split('&'));
      }
      if (src && src.indexOf("?") > -1) {
        iframeParams = iframeParams.concat(src.substr(src.indexOf("?") + 1).split("&"));
        src = src.substr(0, src.indexOf("?"))
      }
      iframeParams.push("isIframeEmbed=1");
      ifr.src = src + "?" + iframeParams.join('&');
    }
    window.handleIFrameMessage = function(e) {
      if (typeof e.data === 'object') { return; }
      var args = e.data.split(":");
      if (args.length > 2) { iframe = document.getElementById("JotFormIFrame-" + args[(args.length - 1)]); } else { iframe = document.getElementById("JotFormIFrame"); }
      if (!iframe) { return; }
      switch (args[0]) {
        case "scrollIntoView":
          iframe.scrollIntoView();
          break;
        case "setHeight":
          iframe.style.height = args[1] + "px";
          if (!isNaN(args[1]) && parseInt(iframe.style.minHeight) > parseInt(args[1])) {
            iframe.style.minHeight = args[1] + "px";
          }
          break;
        case "collapseErrorPage":
          if (iframe.clientHeight > window.innerHeight) {
            iframe.style.height = window.innerHeight + "px";
          }
          break;
        case "reloadPage":
          window.location.reload();
          break;
        case "loadScript":
          if( !window.isPermitted(e.origin, ['[jotform.com](http://jotform.com)', '[jotform.pro](http://jotform.pro)']) ) { break; }
          var src = args[1];
          if (args.length > 3) {
              src = args[1] + ':' + args[2];
          }
          var script = document.createElement('script');
          script.src = src;
          script.type = 'text/javascript';
          document.body.appendChild(script);
          break;
        case "exitFullscreen":
          if      (window.document.exitFullscreen)        window.document.exitFullscreen();
          else if (window.document.mozCancelFullScreen)   window.document.mozCancelFullScreen();
          else if (window.document.mozCancelFullscreen)   window.document.mozCancelFullScreen();
          else if (window.document.webkitExitFullscreen)  window.document.webkitExitFullscreen();
          else if (window.document.msExitFullscreen)      window.document.msExitFullscreen();
          break;
      }
      var isJotForm = (e.origin.indexOf("jotform") > -1) ? true : false;
      if(isJotForm && "contentWindow" in iframe && "postMessage" in iframe.contentWindow) {
        var urls = {"docurl":encodeURIComponent(document.URL),"referrer":encodeURIComponent(document.referrer)};
        iframe.contentWindow.postMessage(JSON.stringify({"type":"urls","value":urls}), "*");
      }
    };
    window.isPermitted = function(originUrl, whitelisted_domains) {
      var url = document.createElement('a');
      url.href = originUrl;
      var hostname = url.hostname;
      var result = false;
      if( typeof hostname !== 'undefined' ) {
        whitelisted_domains.forEach(function(element) {
            if( hostname.slice((-1 * element.length - 1)) === '.'.concat(element) ||  hostname === element ) {
                result = true;
            }
        });
        return result;
      }
    };
    if (window.addEventListener) {
      window.addEventListener("message", handleIFrameMessage, false);
    } else if (window.attachEvent) {
      window.attachEvent("onmessage", handleIFrameMessage);
    }
    </script>

This is my iframe js