Netlify表单-提交后将其重定向到错误的页面

时间:2020-05-18 09:56:43

标签: forms gatsby netlify netlify-function

我有一个从Netlify运行的Gatsby.js项目。对于联系表格,我使用的是Netlify的api。

内容是多语言的,因此我在/contact//en/contact/上有一个联系页面,这些页面显然与表单共享相同的代码。我已经在/form-succes//en/form-succes/

上创建了成功的表单提交页面

但是当我站在荷兰这边并且提交表单时,我看到网址转到/form-succes一秒钟,然后转到(重定向?)到/en/form-succes

它在本地环境中运行良好,但在Netlify上构建后却无法运行。

这是Netlify问题还是我做错了什么?

这是表格的一部分:

var pathPrefix取决于语言//en/

<form
  name={"contact"}
  method="post"
  netlify-honeypot="bot-field"
  data-netlify="true"
  lassName="contact-forms"
  action={`${pathPrefix}form-succes`} // "/form-succes" or "/en/form-succes"
          >
   // input stuff
</form>

1 个答案:

答案 0 :(得分:0)

我最终制作了两个Netlify表单。一种针对每种语言。 Netlify提供的文档不起作用。

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <!doctype html> <html lang="en"> <head> <!-- Required meta tags --> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <!-- Bootstrap CSS --> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous"> <title></title> </head> <body> <table class="table"> <thead> <tr> <th scope="col">#</th> <th scope="col">Person 1</th> <th scope="col">Person 2</th> <th scope="col">Person 3</th> </tr> </thead> <tbody> <tr> <th scope="row">Type 1</th> <td>12</td> <td>25</td> <td>34</td> </tr> <tr> <th scope="row">Type 2</th> <td>4</td> <td>34</td> <td>67</td> </tr> <tr> <th scope="row">Type 3</th> <td>3</td> <td>90</td> <td>67</td> </tr> </tbody> </table> </body> </html>(使用反引号)