Skip to content

Browser content display blocked by MIME type mismatch #3077

Closed
@amrosado

Description

@amrosado

Issue description

For anyone who is interested, I had a problem running tensorboard in Windows preventing anything from displaying in every browser except for internet explorer. The error I received in Firefox Nightly is the following:

The resource from “http://localhost:6006/index.js” was blocked due to MIME type (“text/plain”) mismatch (X-Content-Type-Options: nosniff).

Tensorboard provides files from a prepared zip file (webfiles.zip), but these files were being provided with the 'text/plain' content-type header preventing browsers from using the javascript correctly. The ways to fix this is to go to the following file: tensoboard/backend/http_util.py and change to the following:

path_ext_split = request.path.split('.')
  if path_ext_split[-1] == 'js':
    content_type = 'application/javascript'
      
  if textual and not charset_match and mimetype not in _JSON_MIMETYPES:
    content_type += '; charset=' + charset

You could also disable nosniff by commenting out the following:

headers.append(('X-Content-Type-Options', 'nosniff'))

to

#headers.append(('X-Content-Type-Options', 'nosniff'))

I believe this might be similar to another issue referencing the projector.

The diagnose_tensorboard.py information is not useful. For this particular project, I'm attempting to use tensorboard for a pytorch project.

Environment information (required)

Diagnostics output
--- check: autoidentify
INFO: diagnose_tensorboard.py version d515ab103e2b1cfcea2b096187741a0eeb8822ef

--- check: general
INFO: sys.version_info: sys.version_info(major=3, minor=8, micro=0, releaselevel='final', serial=0)
INFO: os.name: nt
INFO: os.uname(): N/A
INFO: sys.getwindowsversion(): sys.getwindowsversion(major=10, minor=0, build=18362, platform=2, service_pack='')

--- check: package_management
INFO: has conda-meta: False
INFO: $VIRTUAL_ENV: None

--- check: installed_packages
WARNING: no installation among: ['tb-nightly', 'tensorboard', 'tensorflow-tensorboard']
WARNING: no installation among: ['tensorflow', 'tensorflow-gpu', 'tf-nightly', 'tf-nightly-2.0-preview', 'tf-nightly-gpu', 'tf-nightly-gpu-2.0-preview']
WARNING: no installation among: ['tensorflow-estimator', 'tensorflow-estimator-2.0-preview', 'tf-estimator-nightly']

--- check: tensorboard_python_version
Traceback (most recent call last):
  File "C:\Users\arosado\GitClone\tensorboard\tensorboard\tools\diagnose_tensorboard.py", line 470, in main
    suggestions.extend(check())
  File "C:\Users\arosado\GitClone\tensorboard\tensorboard\tools\diagnose_tensorboard.py", line 78, in wrapper
    result = fn()
  File "C:\Users\arosado\GitClone\tensorboard\tensorboard\tools\diagnose_tensorboard.py", line 246, in tensorboard_python_version
    from tensorboard import version
ModuleNotFoundError: No module named 'tensorboard'

--- check: tensorflow_python_version
Traceback (most recent call last):
  File "C:\Users\arosado\GitClone\tensorboard\tensorboard\tools\diagnose_tensorboard.py", line 470, in main
    suggestions.extend(check())
  File "C:\Users\arosado\GitClone\tensorboard\tensorboard\tools\diagnose_tensorboard.py", line 78, in wrapper
    result = fn()
  File "C:\Users\arosado\GitClone\tensorboard\tensorboard\tools\diagnose_tensorboard.py", line 253, in tensorflow_python_version
    import tensorflow as tf
ModuleNotFoundError: No module named 'tensorflow'

--- check: tensorboard_binary_path
INFO: which tensorboard: b'C:\\ProgramData\\Anaconda3\\Scripts\\tensorboard.exe\r\n'

--- check: addrinfos
socket.has_ipv6 = True
socket.AF_UNSPEC = <AddressFamily.AF_UNSPEC: 0>
socket.SOCK_STREAM = <SocketKind.SOCK_STREAM: 1>
socket.AI_ADDRCONFIG = <AddressInfo.AI_ADDRCONFIG: 1024>
socket.AI_PASSIVE = <AddressInfo.AI_PASSIVE: 1>
Loopback flags: <AddressInfo.AI_ADDRCONFIG: 1024>
Loopback infos: [(<AddressFamily.AF_INET6: 23>, <SocketKind.SOCK_STREAM: 1>, 0, '', ('::1', 0, 0, 0)), (<AddressFamily.AF_INET: 2>, <SocketKind.SOCK_STREAM: 1>, 0, '', ('127.0.0.1', 0))]
Wildcard flags: <AddressInfo.AI_PASSIVE: 1>
Wildcard infos: [(<AddressFamily.AF_INET6: 23>, <SocketKind.SOCK_STREAM: 1>, 0, '', ('::', 0, 0, 0)), (<AddressFamily.AF_INET: 2>, <SocketKind.SOCK_STREAM: 1>, 0, '', ('0.0.0.0', 0))]

--- check: readable_fqdn
INFO: socket.getfqdn(): 'DESKTOP-CLRUTHR'

--- check: stat_tensorboardinfo
INFO: directory: C:\Users\arosado\AppData\Local\Temp\.tensorboard-info
INFO: os.stat(...): os.stat_result(st_mode=16895, st_ino=1970324838089767, st_dev=2625741768, st_nlink=1, st_uid=0, st_gid=0, st_size=4096, st_atime=1577322690, st_mtime=1577322690, st_ctime=1577222989)
INFO: mode: 0o40777

--- check: source_trees_without_genfiles
INFO: tensorboard_roots (0): []; bad_roots (0): []

--- check: full_pip_freeze
INFO: pip freeze --all:
pip==19.3.1
setuptools==41.6.0
virtualenv==16.7.7
virtualenvwrapper-win==1.2.5

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions