The plugin documentation

The plugin documentation? You're using normal git integration, added the html contact form as is (needs the data-static-form-name attribute to be set to anything), you have the functions folder in your root (not in your output directory) with the _middleware.ts file, you can see in build logs under the functions tab, the middleware listed under route configuration?
18 Replies
frankjonen
frankjonen2y ago
I have the example form now. Just added lines so it's a little easier to read.
<body>
<h1>Contact us</h1>
<form data-static-form-name="contact">
<label>Email address <input type="email" name="email" /></label>
<hr />
<label>Message <textarea name="message"></textarea></label>
<hr />
<button type="Submit">Send</button>
</form>
</body>
<body>
<h1>Contact us</h1>
<form data-static-form-name="contact">
<label>Email address <input type="email" name="email" /></label>
<hr />
<label>Message <textarea name="message"></textarea></label>
<hr />
<button type="Submit">Send</button>
</form>
</body>
I'm uploading with wrangler. The middleware is in functions/_middleware.ts I'm getting a compiled worker success message before it uploads.
frankjonen
frankjonen2y ago
You mean this with build logs?
frankjonen
frankjonen2y ago
I have this. Which is weird since I never set up any script called submit.
Chaika
ChaikaOP2y ago
Looks like you're missing the middleware What does your functions folder look like? Anything other then _middleware.ts?
frankjonen
frankjonen2y ago
just functions/_middleware.ts
Chaika
ChaikaOP2y ago
and that's in the root of your project (where you're executing pages publish)?
frankjonen
frankjonen2y ago
not sure what you mean but it's in here. Wrangler command is wrangler pages publish temp-out.
Chaika
ChaikaOP2y ago
it needs to be in the folder you are executing the pages publish command from I believe, not the folder you specify as the output directory ex.
project/
/functions/_middleware.ts
/temp-out/...
..other source files
project/
/functions/_middleware.ts
/temp-out/...
..other source files
and you execute wrangler pages publish while in project/
frankjonen
frankjonen2y ago
Well… look what I found in there.
frankjonen
frankjonen2y ago
that's where that comes from. I just copied it away so it's not in the way.
Chaika
ChaikaOP2y ago
(and don't forget to move the current functions folder with the _middleware.ts file up a level)
frankjonen
frankjonen2y ago
and now I'm getting errors. So that's progress. Does Authentication error [code: 10000] mean anything to you?
Chaika
ChaikaOP2y ago
From wrangler?
frankjonen
frankjonen2y ago
yep
Chaika
ChaikaOP2y ago
That's weird if it suddenly started doing it now on publish when it didn't before. I would try again, or log out of wrangler and back in Looks like sometimes if you logged in a really long time ago, the token wrangler got may be missing some newer permissions. If you did the exact same command as you've always done I wouldn't imagine that to be the case though
frankjonen
frankjonen2y ago
Boom! It uploaded. I tested. I got mail! Thank you so much for your patience. I really appreciate it. Damn what a ride. So glad it's finally working.
Chaika
ChaikaOP2y ago
nice! Yea functions can be a bit confusing that they have to be in the root folder, it wouldn't make sense for them to be in the upload directory, but it should still probably warn you that you may be doing something wrong
frankjonen
frankjonen2y ago
I had no doubt the functions go with the page content. The docs only talk about them in isolation, never in context. It just seemed logical. Especially given that I tell wrangler which folder to use. I never thought it would use something outside of that folder. So strange. Glad it's working now though.
Want results from more Discord servers?
Add your server