You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Postman Mock Server生成的URL是否始终为HTTPS?如何创建HTTP协议的Mock URL?

Can't Get an HTTP Postman Mock Server URL (Only Getting HTTPS)

Hey there! Let's break this down clearly:

First off, the reason your Postman Mock Server URL is HTTPS-only is because all of Postman's cloud-hosted Mock Servers default to HTTPS. This isn't an oversight—it's a security choice from Postman to ensure all traffic to and from their managed services is encrypted. There's no built-in option to generate an HTTP-only URL for their cloud Mock endpoints.

But don't worry, there are workarounds to get an HTTP-compatible Mock setup that works with your .NET Web API (which only supports HTTP):

Option 1: Run a Local Postman Mock Server

This is the most straightforward fix if you need an HTTP endpoint. Postman lets you run Mock Servers directly on your local machine, which can use HTTP:

  • Open your target collection in Postman.
  • Click the three-dot menu (...) next to the collection name, then select Mock Collection.
  • In the setup window, look for the Location option and choose Run locally instead of Postman Cloud.
  • Pick a port number (like 8080) and configure any other settings you need, then start the Mock Server.
  • You'll get an HTTP URL like http://localhost:8080/path—perfect for your API's requirements.

Option 2: Use a Local Proxy to Convert HTTPS to HTTP

If you need to keep using Postman's cloud Mock Server but need an HTTP endpoint, set up a simple local proxy to forward traffic:

  • Tools like nginx, http-proxy-middleware (Node.js), or even a basic Python script can do this. For example, here's a quick Node.js proxy using http-proxy-middleware:
    const express = require('express');
    const { createProxyMiddleware } = require('http-proxy-middleware');
    
    const app = express();
    
    // Forward HTTP requests from localhost:8000/path to your Postman Mock URL
    app.use('/path', createProxyMiddleware({
      target: 'https://511d28ba-e0aa-438e-b226-a2a77dbf0d1b.mock.pstmn.io',
      changeOrigin: true,
      secure: false // Disable SSL verification for local testing if needed
    }));
    
    app.listen(8000, () => {
      console.log('HTTP proxy running at http://localhost:8000');
    });
    
    Now you can send HTTP requests to http://localhost:8000/path, and the proxy will forward them to your HTTPS Postman Mock Server behind the scenes.

Option 3: Add HTTPS Support to Your .NET Web API (Long-Term Fix)

While this isn't immediate, enabling HTTPS on your API is a best practice (even for testing). It's easy to set up with a self-signed certificate:

  • Run dotnet dev-certs https --trust in your terminal to generate and trust a local development certificate.
  • Update your project's launchSettings.json to include an HTTPS profile, or use the .NET CLI to run your API with dotnet run --launch-profile https.

Quick Recap

Postman's cloud Mock Servers don't support HTTP, but you can either run a local Mock Server directly, proxy the HTTPS traffic to HTTP, or (ideally) enable HTTPS on your API to align with modern security standards.

内容的提问来源于stack exchange,提问作者Walker66

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.28 21:57:27