Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google Cloud Run HTTPS errors #152

Open
blackshot opened this issue Feb 4, 2021 · 0 comments
Open

Google Cloud Run HTTPS errors #152

blackshot opened this issue Feb 4, 2021 · 0 comments

Comments

@blackshot
Copy link

blackshot commented Feb 4, 2021

when zero app is deployed on Google Cloud Run everything works except http api calls because they get blocked because of "Mixed Content"

example:
route /api/users (python handler)

from flask import jsonify
def handler():
    return jsonify(users=[f"u{i}" for i in range(10)])

and some React component with api call at /index.tsx

function Users(){
    const [users, setUsers] = useState(null)
    useEffect(() => {
        fetch('/api/users').then(res=>{
            const {ok} = res;
            if (!ok) throw new Error("Error searching users");
            return res.json()
        }).then(data=>setUsers(data));
    }, [])

    if (!users) return <span>Loading...</span>
    return(<ol>{users && users.users.map(u => <li key={u}>{u}</li>)}</ol>);
}

results in every api call made to /api/users gets 308 HTTP response (Permanent redirect) to the same url/route (dont know why) then gets blocked because they are not using HTTPS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant