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
frankjonen14mo 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
frankjonen14mo ago
You mean this with build logs?
frankjonen
frankjonen14mo ago
I have this. Which is weird since I never set up any script called submit.
Chaika
Chaika14mo ago
Looks like you're missing the middleware What does your functions folder look like? Anything other then _middleware.ts?
frankjonen
frankjonen14mo ago
just functions/_middleware.ts
Chaika
Chaika14mo ago
and that's in the root of your project (where you're executing pages publish)?
frankjonen
frankjonen14mo ago
not sure what you mean but it's in here. Wrangler command is wrangler pages publish temp-out.
Chaika
Chaika14mo 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
frankjonen14mo ago
Well… look what I found in there.
frankjonen
frankjonen14mo ago
that's where that comes from. I just copied it away so it's not in the way.
Chaika
Chaika14mo ago
(and don't forget to move the current functions folder with the _middleware.ts file up a level)
frankjonen
frankjonen14mo ago
and now I'm getting errors. So that's progress. Does Authentication error [code: 10000] mean anything to you?
Chaika
Chaika14mo ago
From wrangler?
frankjonen
frankjonen14mo ago
yep
Chaika
Chaika14mo 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
frankjonen14mo 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
Chaika14mo 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
frankjonen14mo 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.