Skip to content

Commit

Permalink
Merge branch 'main' into pnpm-no-hoist
Browse files Browse the repository at this point in the history
  • Loading branch information
bluwy committed Sep 27, 2022
2 parents d587153 + 90c2072 commit d7afd58
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 87 deletions.
5 changes: 5 additions & 0 deletions .changeset/curvy-comics-smash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/vercel': patch
---

Set SSR target webworker
5 changes: 5 additions & 0 deletions .changeset/famous-camels-study.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

add warning for post routes called when output is not server
2 changes: 1 addition & 1 deletion packages/astro/src/core/endpoint/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export async function call(
}
const [params] = paramsAndPropsResp;

const response = await renderEndpoint(mod, opts.request, params);
const response = await renderEndpoint(mod, opts.request, params, opts.ssr);

if (response instanceof Response) {
return {
Expand Down
12 changes: 11 additions & 1 deletion packages/astro/src/runtime/server/endpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,19 @@ function getHandlerFromModule(mod: EndpointHandler, method: string) {
}

/** Renders an endpoint request to completion, returning the body. */
export async function renderEndpoint(mod: EndpointHandler, request: Request, params: Params) {
export async function renderEndpoint(
mod: EndpointHandler,
request: Request,
params: Params,
ssr?: boolean
) {
const chosenMethod = request.method?.toLowerCase();
const handler = getHandlerFromModule(mod, chosenMethod);
if (!ssr && ssr === false && chosenMethod && chosenMethod !== 'get') {
// eslint-disable-next-line no-console
console.warn(`
${chosenMethod} requests are not available when building a static site. Update your config to output: 'server' to handle ${chosenMethod} requests.`);
}
if (!handler || typeof handler !== 'function') {
// No handler found, so this should be a 404. Using a custom header
// to signal to the renderer that this is an internal 404 that should
Expand Down
2 changes: 1 addition & 1 deletion packages/integrations/tailwind/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ module.exports = {
## Examples

- The [Astro Tailwind Starter](https://github.com/withastro/astro/tree/latest/examples/with-tailwindcss?on=github) gets you up and running with a base for your project that uses Tailwind for styling
- Astro's homepage uses Tailwind. Check out its [Tailwind configuration file](https://github.com/withastro/astro.build/blob/main/tailwind.config.js) or an [example component](https://github.com/withastro/astro.build/blob/main/src/components/integrations/IntegrationCard.astro)
- Astro's homepage uses Tailwind. Check out its [Tailwind configuration file](https://github.com/withastro/astro.build/blob/main/tailwind.config.cjs) or an [example component](https://github.com/withastro/astro.build/blob/main/src/components/IntegrationCard.astro)
- The [Astro Ink](https://github.com/one-aalam/astro-ink), [Sarissa Blog](https://github.com/iozcelik/SarissaBlogAstroStarter), and [Creek](https://github.com/robertguss/Astro-Theme-Creek) themes use Tailwind for styling
- [Browse Astro Tailwind projects on GitHub](https://github.com/search?q=%22%40astrojs%2Ftailwind%22+filename%3Apackage.json&type=Code) for more examples!

Expand Down
1 change: 1 addition & 0 deletions packages/integrations/vercel/src/edge/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export default function vercelEdge(): AstroIntegration {
}

vite.ssr = {
target: 'webworker',
noExternal: true,
};
}
Expand Down
Loading

0 comments on commit d7afd58

Please sign in to comment.