Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wrangler pages dev 404s some functions/routes #92

Closed
colecrouter opened this issue Dec 10, 2021 · 8 comments · Fixed by #407
Closed

wrangler pages dev 404s some functions/routes #92

colecrouter opened this issue Dec 10, 2021 · 8 comments · Fixed by #407
Labels
pages Relating to Pages

Comments

@colecrouter
Copy link
Contributor

functions/index.ts and functions/*/index.ts , functions/_middleware.ts and functions/*/_middleware.ts work, but nothing else. For example, functions/*/*/index.ts does not work. Parameterized paths also don't work.

I'm on Windows. To repro, open new folder, npm init, npm i wrangler@alpha, create functions folder, create index.ts, insert:

export const onRequestGet: PagesFunction<{}> = async ({ request, env }): Promise<Response> => {
    return new Response("hello1", { status: 200 })
}

Run npx wrangler pages dev ./. Move it to functions/index.ts, http://localhost:8788/ works fine. Move it to functions/test/test/index.ts, http://localhost:8788/test/test/ returns a 404.

The other day, this was happening both when building on Cf and when I tried using wrangler pages dev. Now it's just happening with wrangler. This seems like an isolated case, so let me know if there's any more info I can provide.

@threepointone threepointone added bug pages Relating to Pages labels Dec 12, 2021
@threepointone
Copy link
Contributor

Feels like a bug, we'll investigate this.

@colecrouter
Copy link
Contributor Author

I tried the latest wrangler@alpha, and behaviour has changed. Before, one of the bad routes would respond with my 404.html, now there's nothing at all.

To make sure my project is set up properly, I tried it on WSL and it seems to work fine, but esbuild watch does not work there :(

@threepointone
Copy link
Contributor

@GregBrimble

@elemental-mind
Copy link

Should have put my comment here. It's a bug in the code generator:

#50 (comment)

@colecrouter
Copy link
Contributor Author

colecrouter commented Jan 27, 2022

Last night, I kept getting burned by this bug, so this afternoon, I decided I would take some time to finally fix it. Spent a good 30 minutes setting up the environment, reading the contrib doc, and running my first build, etc.

"Wait, why is it working?"

The build, the one that came out this morning 🤣

Can someone, like @elemental-mind, npm i -g wrangler@beta and confirm it's working now?

EDIT: I take it back, it bootstraps the middleware properly, but that's it. I'll PR.

EDIT AGAIN: See #327

@GregBrimble
Copy link
Member

I think this has likely been closed by #331 . Can you confirm @Mexican-Man ?

@colecrouter
Copy link
Contributor Author

colecrouter commented Feb 9, 2022

Thanks @GregBrimble. I thought that commit would fix it, but it doesn't seem to work. I pulled @alpha and @0.0.16 with no luck. Pulled my PR just to make sure, and it's still working.

I will try to rebase and redo a PR when I have time.

@colecrouter
Copy link
Contributor Author

It seems as though that PR (or another one from 0.0.16) introduced a bug where the "route deduplication" is disregarding methods. This doesn't seem like it would be a Windows exclusive issue, but I've gone ahead and made another PR #465.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pages Relating to Pages
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants