Skip to content

Instantly share code, notes, and snippets.

@Bradan
Bradan / test_server.py
Created August 14, 2020 18:48
Problem with CORS and fetch on same origin. Browser assumes the "same-origin" to be null, but why?
#!/usr/bin/env python3
from http.server import HTTPServer, HTTPStatus, SimpleHTTPRequestHandler, test
import sys
from urllib.parse import urlparse
import os
class TestRequestHandler (SimpleHTTPRequestHandler):
def do_GET(self):
"""Serve a GET request."""
function init() {
fetch("fetch.xml").then(r => r.text()).then(t => console.log(t));
}
window.addEventListener("load", init);