修复跨域问题

This commit is contained in:
2026-07-07 19:15:00 +08:00
parent 72a254d088
commit b9ce3fc971
33 changed files with 220 additions and 10 deletions
+10
View File
@@ -31,7 +31,17 @@ builder.Services.AddSingleton<MtApi5Client>(sp =>
});
builder.Services.AddSingleton(new SemaphoreSlim(1, 1));
builder.Services.AddHostedService<MtConnectionService>();
builder.Services.AddCors(options =>
{
options.AddDefaultPolicy(policy =>
{
policy.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader();
});
});
var app = builder.Build();
app.UseCors();
app.UseExceptionHandler(errorApp =>
{
+67
View File
@@ -0,0 +1,67 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v8.0",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v8.0": {
"Mt5Bridge/1.0.0": {
"dependencies": {
"MtApi5": "2.0.0.0",
"MtClient": "1.0.0.0",
"Newtonsoft.Json": "13.0.0.0"
},
"runtime": {
"Mt5Bridge.dll": {}
}
},
"MtApi5/2.0.0.0": {
"runtime": {
"MtApi5.dll": {
"assemblyVersion": "2.0.0.0",
"fileVersion": "2.0.0.0"
}
}
},
"MtClient/1.0.0.0": {
"runtime": {
"MtClient.dll": {
"assemblyVersion": "1.0.0.0",
"fileVersion": "1.0.0.0"
}
}
},
"Newtonsoft.Json/13.0.0.0": {
"runtime": {
"Newtonsoft.Json.dll": {
"assemblyVersion": "13.0.0.0",
"fileVersion": "13.0.3.27908"
}
}
}
}
},
"libraries": {
"Mt5Bridge/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
},
"MtApi5/2.0.0.0": {
"type": "reference",
"serviceable": false,
"sha512": ""
},
"MtClient/1.0.0.0": {
"type": "reference",
"serviceable": false,
"sha512": ""
},
"Newtonsoft.Json/13.0.0.0": {
"type": "reference",
"serviceable": false,
"sha512": ""
}
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,20 @@
{
"runtimeOptions": {
"tfm": "net8.0",
"frameworks": [
{
"name": "Microsoft.NETCore.App",
"version": "8.0.0"
},
{
"name": "Microsoft.AspNetCore.App",
"version": "8.0.0"
}
],
"configProperties": {
"System.GC.Server": true,
"System.Reflection.Metadata.MetadataUpdater.IsSupported": false,
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
}
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
+5 -5
View File
@@ -1,17 +1,17 @@
{
"format": 1,
"restore": {
"C:\\Users\\Administrator\\Desktop\\Mt5Bridge\\Mt5Bridge.csproj": {}
"C:\\Users\\Administrator\\Desktop\\active-fx-traders\\my-Mt5Bridge\\Mt5Bridge.csproj": {}
},
"projects": {
"C:\\Users\\Administrator\\Desktop\\Mt5Bridge\\Mt5Bridge.csproj": {
"C:\\Users\\Administrator\\Desktop\\active-fx-traders\\my-Mt5Bridge\\Mt5Bridge.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "C:\\Users\\Administrator\\Desktop\\Mt5Bridge\\Mt5Bridge.csproj",
"projectUniqueName": "C:\\Users\\Administrator\\Desktop\\active-fx-traders\\my-Mt5Bridge\\Mt5Bridge.csproj",
"projectName": "Mt5Bridge",
"projectPath": "C:\\Users\\Administrator\\Desktop\\Mt5Bridge\\Mt5Bridge.csproj",
"projectPath": "C:\\Users\\Administrator\\Desktop\\active-fx-traders\\my-Mt5Bridge\\Mt5Bridge.csproj",
"packagesPath": "C:\\Users\\Administrator\\.nuget\\packages\\",
"outputPath": "C:\\Users\\Administrator\\Desktop\\Mt5Bridge\\obj\\",
"outputPath": "C:\\Users\\Administrator\\Desktop\\active-fx-traders\\my-Mt5Bridge\\obj\\",
"projectStyle": "PackageReference",
"configFilePaths": [
"C:\\Users\\Administrator\\AppData\\Roaming\\NuGet\\NuGet.Config"
@@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v8.0", FrameworkDisplayName = ".NET 8.0")]
@@ -0,0 +1,22 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("Mt5Bridge")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Release")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+72a254d088108ba984483d64325ad4a99a15c745")]
[assembly: System.Reflection.AssemblyProductAttribute("Mt5Bridge")]
[assembly: System.Reflection.AssemblyTitleAttribute("Mt5Bridge")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
// 由 MSBuild WriteCodeFragment 类生成。
@@ -0,0 +1 @@
73a436c0ddfd44461ffa8081e17c16a265a632353ba2c55532dfe1190818c1f9
@@ -0,0 +1,19 @@
is_global = true
build_property.TargetFramework = net8.0
build_property.TargetPlatformMinVersion =
build_property.UsingMicrosoftNETSdkWeb = true
build_property.ProjectTypeGuids =
build_property.InvariantGlobalization =
build_property.PlatformNeutralAssembly =
build_property.EnforceExtendedAnalyzerRules =
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = Mt5Bridge
build_property.RootNamespace = Mt5Bridge
build_property.ProjectDir = C:\Users\Administrator\Desktop\active-fx-traders\my-Mt5Bridge\
build_property.EnableComHosting =
build_property.EnableGeneratedComInterfaceComImportInterop =
build_property.RazorLangVersion = 8.0
build_property.SupportLocalizedComponentNames =
build_property.GenerateRazorMetadataSourceChecksumAttributes =
build_property.MSBuildProjectDirectory = C:\Users\Administrator\Desktop\active-fx-traders\my-Mt5Bridge
build_property._RazorSourceGeneratorDebug =
@@ -0,0 +1,17 @@
// <auto-generated/>
global using global::Microsoft.AspNetCore.Builder;
global using global::Microsoft.AspNetCore.Hosting;
global using global::Microsoft.AspNetCore.Http;
global using global::Microsoft.AspNetCore.Routing;
global using global::Microsoft.Extensions.Configuration;
global using global::Microsoft.Extensions.DependencyInjection;
global using global::Microsoft.Extensions.Hosting;
global using global::Microsoft.Extensions.Logging;
global using global::System;
global using global::System.Collections.Generic;
global using global::System.IO;
global using global::System.Linq;
global using global::System.Net.Http;
global using global::System.Net.Http.Json;
global using global::System.Threading;
global using global::System.Threading.Tasks;
Binary file not shown.
@@ -0,0 +1 @@
fa7261daa8f6cd35b2cabdce49d64b4efa111ee76853926074d5c790bfffb9d6
@@ -0,0 +1,28 @@
C:\Users\Administrator\Desktop\active-fx-traders\my-Mt5Bridge\bin\Release\net8.0\Mt5Bridge.exe
C:\Users\Administrator\Desktop\active-fx-traders\my-Mt5Bridge\bin\Release\net8.0\Mt5Bridge.deps.json
C:\Users\Administrator\Desktop\active-fx-traders\my-Mt5Bridge\bin\Release\net8.0\Mt5Bridge.runtimeconfig.json
C:\Users\Administrator\Desktop\active-fx-traders\my-Mt5Bridge\bin\Release\net8.0\Mt5Bridge.dll
C:\Users\Administrator\Desktop\active-fx-traders\my-Mt5Bridge\bin\Release\net8.0\Mt5Bridge.pdb
C:\Users\Administrator\Desktop\active-fx-traders\my-Mt5Bridge\bin\Release\net8.0\MtApi5.dll
C:\Users\Administrator\Desktop\active-fx-traders\my-Mt5Bridge\bin\Release\net8.0\MtClient.dll
C:\Users\Administrator\Desktop\active-fx-traders\my-Mt5Bridge\bin\Release\net8.0\Newtonsoft.Json.dll
C:\Users\Administrator\Desktop\active-fx-traders\my-Mt5Bridge\obj\Release\net8.0\Mt5Bridge.csproj.AssemblyReference.cache
C:\Users\Administrator\Desktop\active-fx-traders\my-Mt5Bridge\obj\Release\net8.0\Mt5Bridge.GeneratedMSBuildEditorConfig.editorconfig
C:\Users\Administrator\Desktop\active-fx-traders\my-Mt5Bridge\obj\Release\net8.0\Mt5Bridge.AssemblyInfoInputs.cache
C:\Users\Administrator\Desktop\active-fx-traders\my-Mt5Bridge\obj\Release\net8.0\Mt5Bridge.AssemblyInfo.cs
C:\Users\Administrator\Desktop\active-fx-traders\my-Mt5Bridge\obj\Release\net8.0\Mt5Bridge.csproj.CoreCompileInputs.cache
C:\Users\Administrator\Desktop\active-fx-traders\my-Mt5Bridge\obj\Release\net8.0\Mt5Bridge.MvcApplicationPartsAssemblyInfo.cache
C:\Users\Administrator\Desktop\active-fx-traders\my-Mt5Bridge\obj\Release\net8.0\staticwebassets.build.json
C:\Users\Administrator\Desktop\active-fx-traders\my-Mt5Bridge\obj\Release\net8.0\staticwebassets.development.json
C:\Users\Administrator\Desktop\active-fx-traders\my-Mt5Bridge\obj\Release\net8.0\staticwebassets\msbuild.Mt5Bridge.Microsoft.AspNetCore.StaticWebAssets.props
C:\Users\Administrator\Desktop\active-fx-traders\my-Mt5Bridge\obj\Release\net8.0\staticwebassets\msbuild.build.Mt5Bridge.props
C:\Users\Administrator\Desktop\active-fx-traders\my-Mt5Bridge\obj\Release\net8.0\staticwebassets\msbuild.buildMultiTargeting.Mt5Bridge.props
C:\Users\Administrator\Desktop\active-fx-traders\my-Mt5Bridge\obj\Release\net8.0\staticwebassets\msbuild.buildTransitive.Mt5Bridge.props
C:\Users\Administrator\Desktop\active-fx-traders\my-Mt5Bridge\obj\Release\net8.0\staticwebassets.pack.json
C:\Users\Administrator\Desktop\active-fx-traders\my-Mt5Bridge\obj\Release\net8.0\scopedcss\bundle\Mt5Bridge.styles.css
C:\Users\Administrator\Desktop\active-fx-traders\my-Mt5Bridge\obj\Release\net8.0\Mt5Bridge.csproj.Up2Date
C:\Users\Administrator\Desktop\active-fx-traders\my-Mt5Bridge\obj\Release\net8.0\Mt5Bridge.dll
C:\Users\Administrator\Desktop\active-fx-traders\my-Mt5Bridge\obj\Release\net8.0\refint\Mt5Bridge.dll
C:\Users\Administrator\Desktop\active-fx-traders\my-Mt5Bridge\obj\Release\net8.0\Mt5Bridge.pdb
C:\Users\Administrator\Desktop\active-fx-traders\my-Mt5Bridge\obj\Release\net8.0\Mt5Bridge.genruntimeconfig.cache
C:\Users\Administrator\Desktop\active-fx-traders\my-Mt5Bridge\obj\Release\net8.0\ref\Mt5Bridge.dll
Binary file not shown.
@@ -0,0 +1 @@
78336b0d7c9548c22381256b41e61d95e308b055ebb5bde17d5389da512a3fb0
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,11 @@
{
"Version": 1,
"Hash": "/8Q34kmS+8VCFusGgof9wH/8eKQGq3WaaUYNad/1wwY=",
"Source": "Mt5Bridge",
"BasePath": "_content/Mt5Bridge",
"Mode": "Default",
"ManifestType": "Build",
"ReferencedProjectsConfiguration": [],
"DiscoveryPatterns": [],
"Assets": []
}
@@ -0,0 +1,3 @@
<Project>
<Import Project="Microsoft.AspNetCore.StaticWebAssets.props" />
</Project>
@@ -0,0 +1,3 @@
<Project>
<Import Project="..\build\Mt5Bridge.props" />
</Project>
@@ -0,0 +1,3 @@
<Project>
<Import Project="..\buildMultiTargeting\Mt5Bridge.props" />
</Project>
+3 -3
View File
@@ -13,11 +13,11 @@
"project": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "C:\\Users\\Administrator\\Desktop\\Mt5Bridge\\Mt5Bridge.csproj",
"projectUniqueName": "C:\\Users\\Administrator\\Desktop\\active-fx-traders\\my-Mt5Bridge\\Mt5Bridge.csproj",
"projectName": "Mt5Bridge",
"projectPath": "C:\\Users\\Administrator\\Desktop\\Mt5Bridge\\Mt5Bridge.csproj",
"projectPath": "C:\\Users\\Administrator\\Desktop\\active-fx-traders\\my-Mt5Bridge\\Mt5Bridge.csproj",
"packagesPath": "C:\\Users\\Administrator\\.nuget\\packages\\",
"outputPath": "C:\\Users\\Administrator\\Desktop\\Mt5Bridge\\obj\\",
"outputPath": "C:\\Users\\Administrator\\Desktop\\active-fx-traders\\my-Mt5Bridge\\obj\\",
"projectStyle": "PackageReference",
"configFilePaths": [
"C:\\Users\\Administrator\\AppData\\Roaming\\NuGet\\NuGet.Config"
+2 -2
View File
@@ -1,8 +1,8 @@
{
"version": 2,
"dgSpecHash": "A5kXayphZIY=",
"dgSpecHash": "G66hRH3mPGs=",
"success": true,
"projectFilePath": "C:\\Users\\Administrator\\Desktop\\Mt5Bridge\\Mt5Bridge.csproj",
"projectFilePath": "C:\\Users\\Administrator\\Desktop\\active-fx-traders\\my-Mt5Bridge\\Mt5Bridge.csproj",
"expectedPackageFiles": [],
"logs": []
}