krishnaik06 / Google-Gemini-Crash-Course

GNU General Public License v3.0
190 stars 147 forks source link

local host refused to connect #1

Open neoisda1 opened 5 months ago

neoisda1 commented 5 months ago

The code seems to run. But the local host is not connecting. I think there is an issue with streamlit.

WARNING streamlit.config: Warning: the config option 'server.enableCORS=false' is not compatible with 'server.enableXsrfProtection=true'. As a result, 'server.enableCORS' is being overridden to 'true'.

More information: In order to protect against CSRF attacks, we send a cookie with each request. To do so, we must specify allowable origins, which places a restriction on cross-origin resource sharing.

If cross origin resource sharing is required, please disable server.enableXsrfProtection.

codehariom commented 5 months ago

The warning you're seeing indicates a conflict in the Streamlit configuration options related to CORS (Cross-Origin Resource Sharing) and XSRF protection (Cross-Site Request Forgery). It's recommending that you either disable XSRF protection or CORS, as having both enabled simultaneously can cause issues.

To resolve this, you have a couple of options:

  1. Disable XSRF Protection: If you don't require XSRF protection in your application, you can disable it. You can do this by modifying your Streamlit script or application code.

    Example:

    import streamlit as st
    
    st.set_option('server.enableXsrfProtection', False)
    
    # Rest of your Streamlit application code
  2. Disable CORS: If you need to enable CORS (Cross-Origin Resource Sharing), you can disable XSRF protection.

    Example:

    import streamlit as st
    
    st.set_option('server.enableCORS', True)
    st.set_option('server.enableXsrfProtection', False)
    
    # Rest of your Streamlit application code

Choose the option that aligns with your application's requirements. If you need both XSRF protection and CORS, you may need to check if there's a newer version of Streamlit that resolves this compatibility issue or consider raising the concern with the Streamlit community or support channels.

Remember to restart your Streamlit application after making these changes for the configurations to take effect.