最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Firebase Genkit Developer UI: "Invalid status code UNAUTHORIZED" After Implementing Authentication - Stack Ove

programmeradmin3浏览0评论

I've recently added authentication to my Genkit app following the migration guide, like so:

import { UserFacingError } from 'genkit';
import { ContextProvider, RequestData } from 'genkit/context';
import { expressHandler, startFlowServer } from '@genkit-ai/express';

const context: ContextProvider<Context> = (req: RequestData) => {
  return {
    auth: req.headers['authorization'],
  };
};

export const simpleFlow = ai.defineFlow(
  {
    name: 'simpleFlow',
  },
  async (input, { context }) => {
    if (!context.auth) {
      throw new UserFacingError("UNAUTHORIZED", "Authorization required.");
    }
    if (input.uid !== context.auth.uid) {
      throw new UserFacingError("UNAUTHORIZED", "You may only summarize your own profile data.");
    }
    // Flow logic here...
  }
);

startFlowServer(
  flows: [withContextProvider(simpleFlow, context)],
  port: 8080
);

While authentication works as expected in my deployed application, I can no longer use the Genkit Developer UI to test my flows. I'm receiving an Invalid status code UNAUTHORIZED error when attempting to execute any flow from the UI.

Is there a way to configure the Genkit Developer UI, or perhaps bypass authentication specifically for local development/testing within the UI, so I can continue to use it for rapid prototyping and debugging of flows? Any suggestions or best practices for handling this situation would be greatly appreciated.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论