File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 4242
4343builder . Services . AddEndpointsApiExplorer ( ) ;
4444
45+ // Allow any localhost origin so the Vite dev server and published frontend
46+ // can reach the API during local Aspire orchestration. The origin port varies
47+ // per run so we match on host only, which is safe for local-only deployment.
48+ builder . Services . AddCors ( options =>
49+ {
50+ options . AddDefaultPolicy ( policy =>
51+ policy
52+ . SetIsOriginAllowed ( origin => new Uri ( origin ) . Host == "localhost" )
53+ . AllowAnyHeader ( )
54+ . AllowAnyMethod ( )
55+ ) ;
56+ } ) ;
57+
4558var app = builder . Build ( ) ;
4659
4760await using ( var scope = app . Services . CreateAsyncScope ( ) )
5164}
5265
5366app . MapGet ( "/" , ( ) => Results . Ok ( new { message = "Bike Tracking API is running." } ) ) ;
67+ app . UseCors ( ) ;
5468app . UseHttpLogging ( ) ;
5569app . MapUsersEndpoints ( ) ;
5670app . MapDefaultEndpoints ( ) ;
You can’t perform that action at this time.
0 commit comments