-
Notifications
You must be signed in to change notification settings - Fork 58
use hono as server #3
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
Conversation
| app.use(compress()) | ||
| // this is here so the workshop app knows when the server has started | ||
| app.head('/', (req, res) => res.status(200).end()) | ||
| app.get('/', () => new Response()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HEAD requests are handled by GET handlers. This is true for Express as well.
| * @fixme Not sure what Kent means by | ||
| * `req.query.search` and `req.search`. | ||
| */ | ||
| const searchParams = new URLSearchParams() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only place I didn't figure out. There's some difference between req.search and req.query.search in Express, and I don't know it what that is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't find req.search in Express API docs. Hmm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kentcdodds, was this logic perhaps originally flawed a bit? Shouldn't it be this:
if (req.query.search !== '') {
// Then remove "search" from query
// and redirect.
}
exercises/05.actions/05.solution.history-revalidation/server/app.js
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When running this locally, I'm getting:
TypeError: ctx.res.body.pipeThrough is not a function
at compress2 (file:///Users/kentcdodds/code/epicweb-dev/react-server-components/node_modules/hono/dist/middleware/compress/index.js:12:41)
|
|
||
| app.use(compress()) | ||
| // this is here so the workshop app knows when the server has started | ||
| app.head('/', (req, res) => res.status(200).end()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking we're ok without this.
What you had before meant that when the browser requested the root of the app you'd just get an empty response instead of the index.html.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HEAD is generally better if you want to check if the app is running. But a good think about it is that you don't have to have an explicit app.head('/') to handle it. As I said, HEAD is handled by GET as a fallback, but will receive no response body, which is precisely what you want for the HEAD request.
This likely means that Upon looking at it, that's precisely what happens: At some point, Why this is happeningThis is triggered by the How to solve thisI had to use |
…nts into use-hono
|
I fixed the previous error, and the app loads mostly fine. The |
|
Bummer. Almost there! |
|
I sent a PR to Artem's fork that might fix the issues: kettanaito#1, didn't find a better way to collaborate, I hope I'm not stepping over or inconveniencing anyone 😅 |
|
FWIW #5 migrates the server to hono and removes the dependency on busboy entirely |
|
I prefer what's happening in #5. Thanks! |
Uh oh!
There was an error while loading. Please reload this page.