Vue IIS部署 api 访问当前站点 代理跳转真实API 问题

Vue IIS部署 api 访问当前站点 代理跳转真实API 问题

先确认 ARR 装没装

IIS 管理器 → 点最上面的服务器名 → 右边功能视图找 "Application Request Routing Cache" 没有找到就是没有装

装步骤

方法一:用 Web Platform Installer(推荐)

  1. 在前端服务器上打开 IIS 管理器
  2. 点最上面的服务器名 → 右边找 "Web Platform Installer"(如果没有,去微软官网下载安装)
  3. 搜索 Application Request Routing
  4. 安装 ARR 3.0(会自动带上依赖)

方法二:直接下载 MSI

  • 下载地址:https://www.iis.net/downloads/microsoft/application-request-routing
  • 选 WebPI 链接或直接下 ARRv3_setup.exe
  • 安装时一路下一步
    打开 IIS 管理器 → 服务器节点 → Application Request Routing Cache → 右边 Server Proxy Settings → 勾选 Enable proxy → 点应用。
    要重启IIS 重新打开IIS

vue web 站点web.config 调整

bash 复制代码
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <clear />
                <rule name="ReverseProxyInboundRule4" stopProcessing="true">
                    <match url="^blog/(.*)" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
                    <action type="Rewrite" url="http://192.168.74.4:8088/{R:1}" />
                </rule>
                <rule name="ReverseProxyInboundRule5" stopProcessing="true">
                    <match url="^moodle/(.*)" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
                    <action type="Rewrite" url="https://xxxx/{R:1}" />
                </rule>
              <rule name="ReverseProxyInboundRule3" stopProcessing="true">
    <match url="^api/(.*)" />
    <action type="Rewrite" url="http://192.168.74.92:7108/api/{R:1}" />
</rule>
                <rule name="API Rule" stopProcessing="true">
                    <match url="^(js|css)(.*)$" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
                    <action type="None" />
                </rule>
                <rule name="Handle History Mode and custom 404/500" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="/" />
                </rule>
                <rule name="SignalR" stopProcessing="true">
                    <match url="^teacherHub/(.*)" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
                    <action type="Rewrite" url="http://localhost:7008/teacherHub" />
                </rule>
            </rules>
        </rewrite>
        <staticContent>
            <remove fileExtension=".pdf" />
            <mimeMap fileExtension=".pdf" mimeType="application/pdf" />
            <mimeMap fileExtension=".properties" mimeType="text/plain" />
            <mimeMap fileExtension=".bcmap" mimeType="octet-stream/bcmap" />
        </staticContent>
        <directoryBrowse enabled="true" />
        <httpProtocol>
            <customHeaders>
                <add name="Access-Control-Allow-Origin" value="*" />
                <add name="Access-Control-Allow-Methods" value="GET,PUT,POST,DELETE,OPTIONS" />
                <add name="Access-Control-Expose-Headers" value="Content-Type" />
                <add name="Access-Control-Allow-Credentials" value="true" />
            </customHeaders>
        </httpProtocol>
    </system.webServer>
</configuration>
相关推荐
徐小夕8 小时前
万字长文!DeepSeek Super-agent × 企业知识库架构深度拆解与落地实践
前端·vue.js·github
陈随易8 小时前
TanStarter,从搭建到支付,一步到位开始赚美元
前端·后端·程序员
前端双越老师8 小时前
程序员 1v1 访谈系列第十二期:普通人没有核心竞争力
前端·ai编程·全栈
柳杉8 小时前
没有写一行代码:我用 Codex 制作 了一个 3D 智慧展厅可视化大屏
前端·ai编程·three.js
IT_陈寒8 小时前
Redis开发实战:从入门到精通
前端·人工智能·后端
恋猫de小郭8 小时前
Flutter Impeller Vulkan 内存持续上涨,问题没想到是文字阴影
android·前端·flutter
0xBADCODE9 小时前
2026 强网杯 Web 题 cwp · 全链路复盘
前端·安全·web安全·网络安全·系统安全·ctf
麦麦麦当劳大王17 小时前
【油猴脚本】Boss直聘 岗位职责复制
开发语言·前端·javascript
小lu飞18 小时前
2026小红书小工具怎么制作:纯前端 ZIP 打包、沙箱限制与笔记挂载流程
前端·笔记·ai·ai编程
只睡四小时18 小时前
Three.js Sub-tick:漏判 60.7%→0
开发语言·javascript·性能优化·ecmascript·游戏开发·three.js·碰撞检测