Title: Add a --cors command line option to stdlib http.server · Issue #135056 · python/cpython · GitHub
Open Graph Title: Add a --cors command line option to stdlib http.server · Issue #135056 · python/cpython
X Title: Add a --cors command line option to stdlib http.server · Issue #135056 · python/cpython
Description: Feature or enhancement Proposal: Add a --cors command line option to the http.server stdlib module, which when specified will add this CORS header to all responses: Access-Control-Allow-Origin: * This is useful during local web developme...
Open Graph Description: Feature or enhancement Proposal: Add a --cors command line option to the http.server stdlib module, which when specified will add this CORS header to all responses: Access-Control-Allow-Origin: * T...
X Description: Feature or enhancement Proposal: Add a --cors command line option to the http.server stdlib module, which when specified will add this CORS header to all responses: Access-Control-Allow-Origin: * T...
Opengraph URL: https://github.com/python/cpython/issues/135056
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Add a --cors command line option to stdlib http.server","articleBody":"# Feature or enhancement\n\n### Proposal:\n\nAdd a `--cors` command line option to the `http.server` stdlib module, which when specified will add this CORS header to all responses:\n```\nAccess-Control-Allow-Origin: *\n```\n\nThis is useful during local web development, which is a common use case for `http.server`. If a user is developing Javascript on one local web server, and making Javascript requests against static assets served by a separately running `python -m http.server`, those requests will fail due to the browser's default cross-origin request policy. With the rise in popularity of tools like pyodide and pyscript, whose implementations are subject to the same Javascript cross-origin request logic, I expect similar use cases to this to become more common. It would be useful for `http.server` to support an open cross-origin response header via the command line like so:\n\n```shell\npython -m http.server --cors\n```\n\nThis allows the user to serve static assets locally that can be requested by Javascript anywhere the server is visible. The new headers are opt-in only, no default behavior is changed without the flag.\n\n### Has this already been discussed elsewhere?\n\nI have already discussed this feature proposal on Discourse\n\n### Links to previous discussion of this feature:\n\nI started a thread about this feature on python-ideas:\nhttps://discuss.python.org/t/any-interest-in-adding-a-cors-option-to-python-m-http-server/92120/10\n\nThe thread has a mixed response. Some are for it, some against, and some are in favor of a more generalized approach. I discussed the feature with some developers in person at Pycon 2025, the result being that there is possibly enough interest to add this feature. \n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-135057\n* gh-149320\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/aisipos","@type":"Person","name":"aisipos"},"datePublished":"2025-06-03T04:38:05Z","url":"https://github.com/python/cpython/issues/135056"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:7bd2ada5-2379-8e97-c007-683b1f3a39ac |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DB96:28BF7E:3BDAAE:5031DD:6AECCA51 |
| html-safe-nonce | a2d5ae3f2d0b0361c270e0766c7db7811307415450a3b550677902a0cd94a2aa |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQjk2OjI4QkY3RTozQkRBQUU6NTAzMUREOjZBRUNDQTUxIiwidmlzaXRvcl9pZCI6IjQ3NDExODYzNDk0MTY4OTMwMDkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | e46a9fd0e401b466e88839b44588c69b117033c05b86a85de7803adc76e00fb4 |
| hovercard-subject-tag | issue:3112357483 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/135056/issue_layout |
| twitter:image | https://opengraph.githubassets.com/19253e0395adf12be74692cb55d2d1cf8e298690a0d64ffd829f161acf901b1a/python/cpython/issues/135056 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/19253e0395adf12be74692cb55d2d1cf8e298690a0d64ffd829f161acf901b1a/python/cpython/issues/135056 |
| og:image:alt | Feature or enhancement Proposal: Add a --cors command line option to the http.server stdlib module, which when specified will add this CORS header to all responses: Access-Control-Allow-Origin: * T... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | aisipos |
| hostname | github.com |
| expected-hostname | github.com |
| None | dc0b519c5798dc1150b88dc4c06a8b9634d0069218dc04e469970e76aad74016 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | db139f0bf57b59bf9a8c4abb0849924d6c6ca559 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width