How to open web preview as web page with Cloud Shell

政雄 木下 25 Reputation points
2024-07-25T04:26:33.0733333+00:00

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

cloudshell_web_preview

Azure Container Instances
Azure Container Instances
An Azure service that provides customers with a serverless container experience.
711 questions
0 comments No comments
{count} vote

1 answer

Sort by: Most helpful
  1. Sedat SALMAN 13,835 Reputation points
    2024-07-25T08:27:36.1+00:00

    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.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.