Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion www/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

# Public API Endpoint (already configured in code)
# This is the Azure Function proxy endpoint for CORS
# PUBLIC_FOUNDRY_API_ENDPOINT=https://onnxruntime-foundry-proxy-hpape7gzf2haesef.eastus-01.azurewebsites.net/api/foundryproxy
# PUBLIC_FOUNDRY_API_ENDPOINT=https://foundry-local-cors-proxy.azurewebsites.net/api/foundryproxy

# Build-time variables
# NODE_ENV=production
Expand Down
12 changes: 10 additions & 2 deletions www/src/routes/models/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import type { FoundryModel, GroupedFoundryModel } from './types';

// Azure Function endpoint for CORS proxy
const FOUNDRY_API_ENDPOINT =
'https://onnxruntime-foundry-proxy-hpape7gzf2haesef.eastus-01.azurewebsites.net/api/foundryproxy';
'https://foundry-local-cors-proxy.azurewebsites.net/api/foundryproxy';

export interface ApiFilters {
device?: string;
Expand Down Expand Up @@ -276,10 +276,18 @@ export class FoundryModelService {
const requestBody = this.buildRequestBody(device, executionProvider, skip, continuationToken);

try {
// NOTE: Content-Type is intentionally "text/plain" (not "application/json").
// This keeps the request a CORS "simple request" so the browser does NOT
// send a preflight OPTIONS. The Azure Functions host intercepts preflight
// OPTIONS before our proxy code runs and returns 204 with no
// Access-Control-Allow-Origin header, which fails CORS. The proxy parses the
// body as JSON regardless of Content-Type, so sending text/plain is safe and
// avoids the preflight entirely. Do not change this back to application/json
// unless platform-level CORS is configured on the Function App.
const response = await fetch(FOUNDRY_API_ENDPOINT, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Content-Type': 'text/plain',
Accept: 'application/json'
},
body: JSON.stringify(requestBody)
Expand Down