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.