Last active
May 10, 2021 01:17
-
-
Save jacopen/a392724565f4c5efa757ebcc5ff8855e to your computer and use it in GitHub Desktop.
CORS tester
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: projectcontour.io/v1 | |
kind: HTTPProxy | |
metadata: | |
name: data | |
spec: | |
virtualhost: | |
fqdn: data.YOUR-DOMAIN | |
corsPolicy: | |
allowCredentials: true | |
allowOrigin: | |
- "http://cors.YOUR-DOMAIN" | |
allowMethods: | |
- GET | |
- POST | |
- OPTIONS | |
allowHeaders: | |
- authorization | |
- cache-control | |
exposeHeaders: | |
- Content-Length | |
- Content-Range | |
maxAge: "10m" | |
routes: | |
- conditions: | |
- prefix: / | |
services: | |
- name: nginx | |
port: 80 | |
--- | |
apiVersion: projectcontour.io/v1 | |
kind: HTTPProxy | |
metadata: | |
name: cors | |
spec: | |
virtualhost: | |
fqdn: cors.YOUR-DOMAIN | |
routes: | |
- conditions: | |
- prefix: / | |
services: | |
- name: nginx | |
port: 80 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: v1 | |
kind: ConfigMap | |
metadata: | |
name: html | |
namespace: default | |
data: | |
index.html: | | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<script type="text/javascript"> | |
function fetchJson() { | |
fetch(document.querySelector("#url").value) | |
.then(response => response.json()) | |
.then(data => document.querySelector("#result").value = data.response) | |
.catch(error => {document.querySelector("#result").value = error}) | |
} | |
</script> | |
</head> | |
<body> | |
<h1>CORS Test</h1> | |
<form> | |
<input type="text" id="url" value="http://data.YOUR-DOMAIN/data.json" size="40" /><br /> | |
<input type="button" onclick="fetchJson(); return false;" value="Fetch" /><br /> | |
<input type="textbox" id="result" size="40" /> | |
</form> | |
</body> | |
</html> | |
data.json: | | |
{"response": "Success"} | |
--- | |
apiVersion: v1 | |
kind: Pod | |
metadata: | |
name: nginx | |
namespace: default | |
labels: | |
run: nginx | |
spec: | |
containers: | |
- image: nginx | |
name: nginx | |
volumeMounts: | |
- mountPath: /usr/share/nginx/html | |
name: html | |
volumes: | |
- name: html | |
configMap: | |
name: html | |
--- | |
apiVersion: v1 | |
kind: Service | |
metadata: | |
labels: | |
run: nginx | |
name: nginx | |
namespace: default | |
spec: | |
ports: | |
- port: 80 | |
protocol: TCP | |
targetPort: 80 | |
selector: | |
run: nginx | |
type: ClusterIP |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment