{"id":8824,"date":"2022-10-11T20:12:50","date_gmt":"2022-10-11T20:12:50","guid":{"rendered":"http:\/\/putridparrot.com\/blog\/?p=8824"},"modified":"2022-10-11T20:12:50","modified_gmt":"2022-10-11T20:12:50","slug":"asp-net-core-and-ingress-rules","status":"publish","type":"post","link":"https:\/\/putridparrot.com\/blog\/asp-net-core-and-ingress-rules\/","title":{"rendered":"ASP.NET core and Ingress rules"},"content":{"rendered":"<p><em>Note: This post was written a while back but sat in draft. I&#8217;ve published this now, but I&#8217;m not sure it&#8217;s relevant to the latest versions etc. so please bear this in mind.<\/em><\/p>\n<p>You&#8217;ve implemented a service using ASP.NET deployed it to Kubernetes and all worked great, you then deploy a front end to use that service (as per the example in the Project Tye repo) again, all worked well. Whilst the Ingress mapped the path \/ to your front end services, the CSS an JS libs all worked fine, but then you change you Ingress route to (for example)<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\napiVersion: networking.k8s.io\/v1\r\nkind: Ingress\r\nmetadata:\r\n  name: ingress\r\n  namespace: default\r\nspec:\r\n  rules:\r\n    - http:\r\n        paths:\r\n          - path: \/frontend\r\n            pathType: Prefix\r\n            backend:\r\n              service: \r\n                name: frontend\r\n                port: \r\n                  number: 80\r\n<\/pre>\n<p>In the above, the rule for the path \/frontend will run the <em>frontend<\/em> service. All looks good so you navigate to http:\/\/your-server-ip\/frontend and, wait a moment. The front end and backend services are working, i.e. you see some HTML and you see results from the backend service but Edge\/Chrome\/whatever reports 404 of bootstrap and your CSS.<\/p>\n<p>The simplest solution, but with the downside that you are putting knowledge of the deployment route into your front end service is to just add the following to Startup.cs<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\napp.UsePathBase(&quot;\/frontend&quot;);\r\n<\/pre>\n<p>Obviously if you&#8217;re using <em>tye<\/em> or your own environment configuration, you might prefer to get the &#8220;\/frontend&#8221; string from the environment configuration instead of hard coding.  <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Note: This post was written a while back but sat in draft. I&#8217;ve published this now, but I&#8217;m not sure it&#8217;s relevant to the latest versions etc. so please bear this in mind. You&#8217;ve implemented a service using ASP.NET deployed it to Kubernetes and all worked great, you then deploy a front end to use [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[200,316,314],"tags":[],"class_list":["post-8824","post","type-post","status-publish","format-standard","hentry","category-asp-net-core","category-ingress","category-kubernetes"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/8824","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/comments?post=8824"}],"version-history":[{"count":4,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/8824\/revisions"}],"predecessor-version":[{"id":9579,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/8824\/revisions\/9579"}],"wp:attachment":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/media?parent=8824"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/categories?post=8824"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/tags?post=8824"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}