remoteinterview / zero

Zero is a web server to simplify web development.

Home Page:https://zeroserver.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Google Cloud Run HTTPS errors

blackshot opened this issue · comments

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