question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

'Missing scheme or netloc" for characters in a string

See original GitHub issue

@dopeboy reports in https://github.com/ottoyiu/django-cors-headers/issues/403#issuecomment-494656909 :

I’m getting a bit of a strange error. This is with 3.0.1

This works fine locally:

CORS_ORIGIN_WHITELIST = ['localhost:3000']

But when on production, when I run a manage.py operation, I get:

SystemCheckError: System check identified some issues:

ERRORS:
?: (corsheaders.E013) Origin '/' in CORS_ORIGIN_WHITELIST is missing scheme or netloc
?: (corsheaders.E013) Origin '/' in CORS_ORIGIN_WHITELIST is missing scheme or netloc
?: (corsheaders.E013) Origin '0' in CORS_ORIGIN_WHITELIST is missing scheme or netloc
?: (corsheaders.E013) Origin '0' in CORS_ORIGIN_WHITELIST is missing scheme or netloc
?: (corsheaders.E013) Origin '0' in CORS_ORIGIN_WHITELIST is missing scheme or netloc
?: (corsheaders.E013) Origin '3' in CORS_ORIGIN_WHITELIST is missing scheme or netloc
?: (corsheaders.E013) Origin ':' in CORS_ORIGIN_WHITELIST is missing scheme or netloc
?: (corsheaders.E013) Origin ':' in CORS_ORIGIN_WHITELIST is missing scheme or netloc
?: (corsheaders.E013) Origin 'a' in CORS_ORIGIN_WHITELIST is missing scheme or netloc
?: (corsheaders.E013) Origin 'c' in CORS_ORIGIN_WHITELIST is missing scheme or netloc
?: (corsheaders.E013) Origin 'h' in CORS_ORIGIN_WHITELIST is missing scheme or netloc
?: (corsheaders.E013) Origin 'h' in CORS_ORIGIN_WHITELIST is missing scheme or netloc
?: (corsheaders.E013) Origin 'l' in CORS_ORIGIN_WHITELIST is missing scheme or netloc
?: (corsheaders.E013) Origin 'l' in CORS_ORIGIN_WHITELIST is missing scheme or netloc
?: (corsheaders.E013) Origin 'o' in CORS_ORIGIN_WHITELIST is missing scheme or netloc
?: (corsheaders.E013) Origin 'o' in CORS_ORIGIN_WHITELIST is missing scheme or netloc
?: (corsheaders.E013) Origin 'p' in CORS_ORIGIN_WHITELIST is missing scheme or netloc
?: (corsheaders.E013) Origin 's' in CORS_ORIGIN_WHITELIST is missing scheme or netloc
?: (corsheaders.E013) Origin 't' in CORS_ORIGIN_WHITELIST is missing scheme or netloc
?: (corsheaders.E013) Origin 't' in CORS_ORIGIN_WHITELIST is missing scheme or netloc
?: (corsheaders.E013) Origin 't' in CORS_ORIGIN_WHITELIST is missing scheme or netloc

This doesn’t work locally:

CORS_ORIGIN_WHITELIST = ['http://localhost:3000']

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:18 (9 by maintainers)

github_iconTop GitHub Comments

35reactions
james-songcommented, Jun 5, 2019

Just add , for host name tail in CORS_ORIGIN_WHITELIST on settings.py

like this

CORS_ORIGIN_WHITELIST = (
    'http://localhost:8080',
)
2reactions
dopeboycommented, Jun 16, 2019

@adamchainz, thanks for being so diligent here. As someone who helps maintain another project, I know the effort that goes into monitoring these issues.

I completely rebuilt my pip library. My pipfile.lock is:

        "django-cors-headers": {
            "hashes": [
                "sha256:5b80bf0f8d7fc6e2bcb4f40781d5ff3661961bbf1982e52daec77241dea3b890",
                "sha256:ebf3e2cf25aa6993b959a8e6a87828ebb3c8fe5bc3ec4a2d6e65f3b8d9b4212c"
            ],
            "index": "pypi",
            "version": "==3.0.2"
        },

Locally, I can confirm this doesn’t work (expected):

CORS_ORIGIN_WHITELIST = [      
    'localhost:3000'
]   

And this does work (expected):

CORS_ORIGIN_WHITELIST = [      
    'http://localhost:3000'
]   

I also tested on production with my URL and it works as expected - no longer getting those netloc errors. Not sure if there was something wrong with my pip install or if the new version fixed something but all is well for me. @SHxKM - want to try completely clearing your pip lib and reinstalling?

Thanks again for your support.

Read more comments on GitHub >

github_iconTop Results From Across the Web

urlparse fails with simple url - python
According to https://www.rfc-editor.org/rfc/rfc1738#section-2.1: Scheme names consist of a sequence of characters. The lower case letters ...
Read more >
urllib.parse — Parse URLs into components — Python 3.11.1 ...
This module defines a standard interface to break Uniform Resource Locator (URL) strings up in components (addressing scheme, network location, path etc.), to ......
Read more >
utils/url.py · hemamaps/Scrapy
... (>63 characters) # or missing labels (e.g. http://.example.com) try: netloc ... if not for proper URL expected by remote website. try: scheme,...
Read more >
Missing characters to make a string Pangram
Pangram is a sentence containing every letter in the English alphabet. Given a string, find all characters that are missing from the string, ......
Read more >
urllib.parse — PyData Theme documentation
The empty string classifies URLs with no scheme specified, ... if not netloc or netloc.isascii(): return # looking for characters like \u2100 that...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found