I have flask code and I have enabled the CORS in it. I want to check which security headers it is passing or is it enabled.
How to check it, since it is deployed as service in kubernetes?
I have deployed the code as the service in K8s. I want to check security headers being passed by code when i submit a request
@app.route("/")
@cross_origin()
def helloWorld():
return "Hello, cross-origin-world!"
In my view , it has nothing to do with code as my question is how to check if I enable the cors but since it is asked by one of the expert, I am sharing yaml file similar to one I use. I have not defined anything related to cors here.
apiVersion: networking.k8s.io/v1beta1 kind: Ingress metadata: name: test-ingress annotations: nginx.ingress.kubernetes.io/rewrite-target: / spec: rules:
The easiest way to access an application exposed as a service from your local machine for debugging is port-forwad. Try kubectl port-forward -h
. The relevant example is:
# Listen on ports 5000 and 6000 locally, forwarding data to/from ports 5000 and 6000 in a pod selected by the service
kubectl port-forward service/myservice 5000 6000
You can specify source:target ports e.g. from 8080:5000 if you want to listen on 8080 on localhost but the service's port is 5000.
Then, you can access this via curl or a browser using localhost:$port
. $port is either whatever you chose to listen on. If you service is not in the default namespace, you need to specify the namespace as well -n mynamespace
.