-
Notifications
You must be signed in to change notification settings - Fork 14
Diberry/fix #62
base: main
Are you sure you want to change the base?
Diberry/fix #62
Conversation
Makes totally sense your thought Dina. I will take a look about it and then make some changes right now! Thanks for pointing out this! |
|
Hi @diberry, thanks for catching that. I made a resource about it and it’s important to clarify how openai-service.ts runs entirely on the server even though it lives under lib/services and not in the server/ folder. Here’s a detailed, step-by-step explanation: 1. Project StructureEven though openai-service.ts is outside of 2. Imported Only in Remix Actions (Server)In import { ActionFunction } from "@remix-run/node";
import { azureOpenAIService } from "../../lib/services/openai-service";
export const action: ActionFunction = async ({ request }) => {
// we call our OpenAI service here
const generated = await azureOpenAIService.generateMicroblogContent(/* … */);
return new Response(JSON.stringify({ success: true, content: generated }));
};
// Below is the React component that renders the form and triggers the action
export default function Generate() { /* … */ }
3. How Remix Separates BundlesRemix (and its Vite build) produces two distinct outputs:
Remix automatically tree-shakes out any module used exclusively by loaders/actions, so it never ends up in the client bundle. 4. Why
|
This application appears to use the OpenAI secrets in the client application. Is that true and why is that necessary? That seems unsecure.
How is Remix/Vite building the secrets into the static client?
Typically I only have the backend URL added to the static front end build and all the secrets are on the backend.
There is still an issue with the infra that the OpenAI key and endpoint aren't actually in the Key Vault. That needs to be fixed.