I am new to API gateways and have a question of understanding.
(我是API网关的新手,有一个了解的问题。)
I try too put a series of (micro)services behind an endpoint. (我也尝试在端点后面放置一系列(微)服务。)
For this purpose, I have set up an ASP.NET Core Application and added the package ThreeMammals Ocelot .
(为此,我建立了一个ASP.NET Core应用程序并添加了软件包ThreeMammals Ocelot 。)
With the help of documentation I have configured the Up- and Downstreams. (借助文档,我已经配置了上游和下游。)
So far, so good. (到目前为止,一切都很好。)
The client makes a request to http://mygateway:4242/s1/ {api} and, for example, get a JSON or XML response from Service1, as expected.
(客户端向http:// mygateway:4242 / s1 / {api}发出请求,例如,按预期从Service1获取JSON或XML响应。)
Same behavior for http://mygateway:4242/s2/ {api} with also the expected result!
(http:// mygateway:4242 / s2 / {api}的行为相同,并且预期结果相同!)
My understanding problem is with Service3.
(我的理解问题是Service3。)
When I send a request to http://mygateway/s3/ , I get the index.html as response. (当我向http:// mygateway / s3 /发送请求时,得到index.html作为响应。)
The index.html itself requires the CSS-File 'xyz.css' via link-tag and forces the client to load the file.
(index.html本身需要通过链接标签的CSS文件'xyz.css',并强制客户端加载文件。)
<head>
<link rel="stylesheet" type="text/css" href="xyz.css">
</head>
The request URL the client send to "mygateway" in this case is http://mygateway:4242/xyz.css and not http://mygateway:4242/ s3 /xyz.css and so the respone is a 404 not found, since the "mygateway" knows nothing about a "xyz.css"
(在这种情况下,客户端发送到“ mygateway”的请求URL是http:// mygateway:4242 / xyz.css,而不是http:// mygateway:4242 / s3 / xyz.css,因此,未响应是404,因为“ mygateway”对“ xyz.css”一无所知)
How can I fix this routing(?) issue?
(如何解决此路由(?)问题?)
Is it possible to solve this problem with ocelot middleware?
(使用ocelot中间件可以解决此问题吗?)
Or do I need something else for the service (Service3) with the SinglePageApplication (SPA)? (还是我需要带有SinglePageApplication(SPA)的服务(Service3)的其他产品?)
Maybe is it simply not possible or wrong to place the SPA behind the gateway?
(将SPA放置在网关后面可能根本就是不可能或错误吗?)
I hope you can give me some tips to get access to a SPA or MVC website behind a gateway. (希望您能给我一些提示,以访问网关后面的SPA或MVC网站。)
Thanks iBot
(谢谢iBot)
UPATE: Enclosed the code of index.html.
(UPATE:包含index.html的代码。)
I think that's straight forward. (我认为这很简单。)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Title</title>
<base href="/" />
<link rel="stylesheet" type="text/css" href="dist/xyz.css">
</head>
<body>
<div id="appContainer"></div>
<script src="dist/xyz.js" asp-append-version="true"></script>
</body>
</html>
ask by mMilk translate from so