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

feat(vite-plugin-nitro): add server event to load function and types #614

Merged
merged 3 commits into from
Aug 26, 2023

Conversation

brandonroberts
Copy link
Member

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

Which package are you modifying?

  • vite-plugin-angular
  • vite-plugin-nitro
  • astro-angular
  • create-analog
  • router
  • platform
  • content
  • nx-plugin
  • trpc

What is the current behavior?

Access to the event object from H3 is not available in the load function

Closes #606

What is the new behavior?

Access to the event object from H3 is available in the load function. This allows you to set/read cookies, form data, and access other information derived from the event.

import { PageServerLoad } from '@analogjs/router';
import { parseCookies } from 'h3';

export function load({ event }: PageServerLoad) {
  const cookies = parseCookies(event);
  console.log('cookies', cookies);

  return {
    loaded: true,
  };
}

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

[optional] What gif best describes this PR or how it makes you feel?

@netlify
Copy link

netlify bot commented Aug 24, 2023

Deploy Preview for analog-docs ready!

Name Link
🔨 Latest commit 58b2cbe
🔍 Latest deploy log https://app.netlify.com/sites/analog-docs/deploys/64e897986b68f30008c4c881
😎 Deploy Preview https://deploy-preview-614--analog-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@netlify
Copy link

netlify bot commented Aug 24, 2023

Deploy Preview for analog-blog ready!

Name Link
🔨 Latest commit 58b2cbe
🔍 Latest deploy log https://app.netlify.com/sites/analog-blog/deploys/64e8979828fd1f00083a5f21
😎 Deploy Preview https://deploy-preview-614--analog-blog.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@netlify
Copy link

netlify bot commented Aug 24, 2023

Deploy Preview for analog-app ready!

Name Link
🔨 Latest commit 58b2cbe
🔍 Latest deploy log https://app.netlify.com/sites/analog-app/deploys/64e897985c06d100088120b5
😎 Deploy Preview https://deploy-preview-614--analog-app.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@brandonroberts brandonroberts merged commit b69987a into main Aug 26, 2023
@brandonroberts brandonroberts deleted the feat-server-load-event branch August 26, 2023 23:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cookies forwarding in load function
1 participant