Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

craigwebster169's avatar

InertiaJS on K8S

I'm currently learning K8S and I've followed the Chris Vermeulen blog using InertiaJS/React/Breeze and I'm almost there ! I'm stuck on how to allow the [::]:5173 requests through the ingress to the webserver. Does anyone have any ideas around this, or how I could change the client requests to @react-refresh, client, app.jsx, Welcome.jsx to a prefixed URL which I could then route to port 5173 on the Webserver?

0 likes
2 replies
LaryAI's avatar
Level 58

To allow the [::]:5173 requests through the ingress to the webserver, you can modify the InertiaJS client requests to use a prefixed URL that can be routed to port 5173 on the webserver.

Here's how you can achieve this:

  1. Update the client-side code to use a prefixed URL. In your app.jsx file, change the createInertiaApp function call to include the url option with the desired prefix. For example:
import { createInertiaApp } from '@inertiajs/inertia-react';

createInertiaApp({
  resolve: (name) => require(`./Pages/${name}`),
  setup({ el, App, props }) {
    // ...
  },
  url: (url) => {
    // Add the prefix to the URL
    return `/prefix${url}`;
  },
});
  1. Configure your Kubernetes ingress to route requests with the prefix /prefix to port 5173 on the webserver. You'll need to update your ingress configuration file to include a new rule for this. Here's an example:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: your-ingress
spec:
  rules:
    - http:
        paths:
          - path: /prefix
            pathType: Prefix
            backend:
              service:
                name: your-webserver-service
                port:
                  number: 5173

Replace your-ingress with the name of your ingress resource, your-webserver-service with the name of your webserver service, and make sure to apply this configuration to your Kubernetes cluster.

With these changes, the InertiaJS client requests will be sent to the prefixed URL, which will be routed to port 5173 on the webserver through the Kubernetes ingress.

craigwebster169's avatar

Ok, that's on the right track, but surely we need to open up 5173 on the deployment and service as well?

Please or to participate in this conversation.