Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Discussion options

You must be logged in to vote

Thanks for your feedback, Using MiddlewareHandler, the UnstableMiddleware is deprecated.
https://modernjs.dev/zh/guides/advanced-features/web-server.html#middleware

You can try to code it like this:

import { defineServerConfig, type MiddlewareHandler } from '@modern-js/server-runtime';

const googleAuthHandler: MiddlewareHandler = googleAuth({
    client_id: Bun.env.GOOGLE_ID,
    client_secret: Bun.env.GOOGLE_SECRET,
    scope: ['openid', 'email', 'profile'],
});

const googleRouteHandler: MiddlewareHandler = (c) => {
  const token = c.get('token')
  const grantedScopes = c.get('granted-scopes')
  const user = c.get('user-google')

  return c.json({
    token,
    grantedScopes,
    user,
…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@RuBAN-GT
Comment options

Answer selected by RuBAN-GT
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants