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.

Unable to set the enableCORS configuration to false

See original GitHub issue

Summary

I’m running my streamlit app inside a docker container and using nginx inside a Digital Ocean box to redirect traffic arriving to my.url/crime to the port I’ve mapped for the container, however, the screen hangs on ‘Please Wait’. I’ve done some research and apparently I need to set the config file enableCORS variable to false. I’ve tried changing setting it to false with the following:

  • Dockerfile CMD is streamlit run --server.enableCORS false app.py
  • Dockerfile setting environmental variable to: – ENV STREAMLIT_CONFIG_SERVER_ENABLE_CORS=false – ENV STREAMLIT_CONFIG_SERVER_ENABLECORS=false

However, when I run streamlit config show inside the container, enableCORS is always true

Steps to reproduce

The project is in the following link: https://github.com/dsharpc/StreamlitCrime

And the Dockerfile is this: https://github.com/dsharpc/StreamlitCrime/blob/master/Dockerfile

When the image is run using any of the three variations to set the enableCORS variable to false, the streamlit config show command keeps showing it as true.

Expected behavior:

enableCORS shows as false.

# Enables support for Cross-Origin Request Sharing, for added security. # Default: true enableCORS = false

Actual behavior:

enableCORS still shows as true

# Enables support for Cross-Origin Request Sharing, for added security. # Default: true enableCORS = true

Is this a regression?

First time I’ve tried it

Debug info

  • Streamlit version: 0.51.0
  • Python version: 3.6.8
  • Using Docker
  • OS version: Ubuntu 18.04
  • Browser version:

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
monchiercommented, Dec 18, 2019

Can you try to run this script and see what you see?

import streamlit as st
st.write(st.config.get_option("server.enableCORS"))

I also tried this and seems fine:

streamlit config show --server.enableCORS true|grep CORS
2019-12-18T10:54:51Z.492 DEBUG   streamlit.logger: Initialized tornado logs
enableCORS = true
$ streamlit config show --server.enableCORS false|grep CORS
2019-12-18T10:54:56Z.685 DEBUG   streamlit.logger: Initialized tornado logs
enableCORS = false

This may be unrelated, but may help. Did you configure Nginx for Websockets? You need a config like this one: https://gist.github.com/monchier/f2e7e7eff4324555cfc07a7359a1a631

Can you attach what you see in the network tab of Google Chrome Tools?

Best, Matteo

0reactions
slntoppcommented, Jun 30, 2022

same 😦 and with enableXsrfProtection

Read more comments on GitHub >

github_iconTop Results From Across the Web

Asp.Net WebApi2 Enable CORS not working with AspNet. ...
It's not working unless I modify the web.config. I installed WebApi Cors dependency: install-package Microsoft.AspNet.WebApi.Cors -ProjectName MyProject.Web.Api.
Read more >
Enabling Cross-Origin Requests in ASP.NET Web API 2
This tutorial shows how to enable CORS in your Web API application. ... This section assumes you already know how to create Web...
Read more >
Enabling CORS in ASP.NET Core By Example
Let's learn about enabling CORS in ASP.NET Core, what is the Same Origin Policy and how CORS works with different policies.
Read more >
Enabling CORS support for an API
For details on how to configure an OpenAPI 3.0 API definition, ... To enable CORS support for an existing API, click the title...
Read more >
ASP.NET Core and CORS Gotchas - Rick Strahl's Web Log
Alas those calls failed and upon closer inspection it was due to the fact that the CORS headers weren't getting sent. CORS Setup...
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