Ensure your web application is configured to serve HTML content. In your case, you're using serve, which should automatically handle serving HTML files. If you're building a custom app, ensure your server-side code (Node.js, Python, etc.) is sending the correct content-type headers (Content-Type: text/html). After launching your app and setting up port forwarding, click the Web Preview button in the Cloud Shell toolbar. It typically looks like a square with an arrow pointing outward. Choose the correct port (3000) from the dropdown.
How to open web preview as web page with Cloud Shell
政雄 木下
25
Reputation points
I am considering launching an administrative web app (e.g. mongo-express) from Cloud Shell and opening the administrative web app page in Web Preview.
I could launch the admin app and open it in Web preview, but it would be displayed as just text, not a web page.
Is there a way to display Web preview as a web page?
Reproduction code (using serve)
mkdir -p test && cd test
npm install serve
npx serve .
# default: run on localhost:3000
# set Web preview's port 3000, and launch web preview