mirror of
https://github.com/withastro/astro.git
synced 2025-01-06 22:10:10 -05:00
d6edc75408
* quality of life updates for `App` (#9579) * feat(app): writeResponse for node-based adapters * add changeset * Apply suggestions from code review Co-authored-by: Emanuele Stoppa <my.burning@gmail.com> * Apply suggestions from code review Co-authored-by: Emanuele Stoppa <my.burning@gmail.com> * add examples for NodeApp static methods * unexpose createOutgoingHttpHeaders from public api * move headers test to core * clientAddress test * cookies test * destructure renderOptions right at the start --------- Co-authored-by: Emanuele Stoppa <my.burning@gmail.com> * Fallback node standalone to localhost (#9545) * Fallback node standalone to localhost * Update .changeset/tame-squids-film.md * quality of life updates for the node adapter (#9582) * descriptive names for files and functions * update tests * add changeset * appease linter * Apply suggestions from code review Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com> * `server-entrypoint.js` -> `server.js` * prevent crash on stream error (from PR 9533) * Apply suggestions from code review Co-authored-by: Luiz Ferraz <luiz@lferraz.com> * `127.0.0.1` -> `localhost` * add changeset for fryuni's fix * Apply suggestions from code review * Apply suggestions from code review Co-authored-by: Emanuele Stoppa <my.burning@gmail.com> --------- Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com> Co-authored-by: Luiz Ferraz <luiz@lferraz.com> Co-authored-by: Emanuele Stoppa <my.burning@gmail.com> * chore(vercel): delete request response conversion logic (#9583) * refactor * add changeset * bump peer dependencies * unexpose symbols (#9683) * Update .changeset/tame-squids-film.md Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> --------- Co-authored-by: Arsh <69170106+lilnasy@users.noreply.github.com> Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com> Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com> Co-authored-by: Luiz Ferraz <luiz@lferraz.com> Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
1.1 KiB
1.1 KiB
astro |
---|
minor |
Adds new helper functions for adapter developers.
Astro.clientAddress
can now be passed directly to theapp.render()
method.
const response = await app.render(request, { clientAddress: "012.123.23.3" })
- Helper functions for converting Node.js HTTP request and response objects to web-compatible
Request
andResponse
objects are now provided as static methods on theNodeApp
class.
http.createServer((nodeReq, nodeRes) => {
const request: Request = NodeApp.createRequest(nodeReq)
const response = await app.render(request)
await NodeApp.writeResponse(response, nodeRes)
})
- Cookies added via
Astro.cookies.set()
can now be automatically added to theResponse
object by passing theaddCookieHeader
option toapp.render()
.
-const response = await app.render(request)
-const setCookieHeaders: Array<string> = Array.from(app.setCookieHeaders(webResponse));
-if (setCookieHeaders.length) {
- for (const setCookieHeader of setCookieHeaders) {
- headers.append('set-cookie', setCookieHeader);
- }
-}
+const response = await app.render(request, { addCookieHeader: true })