I'm trying to make a GET request to an application in Kubernetes (GKE) but is always returning 400 Bad Request.
The POST, PUT and DELETE methods are working perfectly.
And the strangest thing is that when I use the port-forward directly to the pod I haven't problem with the GET request.
I've tried to minimize the code of my application as much as possible and it looks like this:
const express = require('express')
const app = express()
const port = 3000
app.use(express.json())
app.use(express.urlencoded({ extended: true }))
app.get('/', (req, res) => {
res.send(req.body)
})
app.post('/', function(req, res){
res.send(req.body);
});
app.put('/', function(req, res){
res.send(req.body);
});
app.delete('/', function(req, res){
res.send(req.body);
});
app.listen(port, () => {
console.log(`Listening to port ${port}`)
})
I think that the problem is in my Ingress configuration because with port-forward it is working well. Here is my Ingress yaml:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: test-ingress
spec:
tls:
- hosts:
- my-test-host
secretName: tls-secret
rules:
- host: my-test-host
http:
paths:
- path: /*
backend:
serviceName: my-test-service
servicePort: 3000
Finally, this is the request that always return 400.
curl --location --request GET 'https://my-test-host/' \
--header 'Content-Type: application/json' \
--data-raw '{
"test": "123"
}'
The same request with other methods (POST, PUT or DELETE) is working well. Please, what I'm doing wrong?