如何将 React localhost (127.0.0.1:3000) 更新到另一个域 (local.example.com) [英] How to update React localhost (127.0.0.1:3000) to another domain (local.example.com)

查看:59
本文介绍了如何将 React localhost (127.0.0.1:3000) 更新到另一个域 (local.example.com)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在设置一个 Localhost 域,以便它可以与此第三方 API 和身份验证服务器进行通信.例如,将 127.0.0.1 更改为 local.example.com

I am setting up a Localhost domain so it can communicate with this third-party API and Auth servers. For example, change 127.0.0.1 to local.example.com

local.example.com 是此第三方企业列入白名单的域.我需要设置它,以便我可以运行 API 路由到它.

local.example.com is the domain whitelisted with this third-party enterprise. I need to set this up so i can run API routes to it.

我能够在 C:\Windows\System32\drivers\etc\hosts 文件中本地更改 127.0.0.1,现在 Node.js 正在其上运行.

I was able to change 127.0.0.1 locally in C:\Windows\System32\drivers\etc\hosts file and now Node.js is running on it.

我将 webpack config devServer - host 添加到 local.example.com 但端口仍然存在.我需要了解如何更改它以进行反应,因为现在它正在移植到 local.example.com:3000.

I added the webpack config devServer - host to local.example.com but the port is still there. I need to understand how to change this for react because right now it's porting to local.example.com:3000.

推荐答案

聚会有点晚,但它仍然可能有用.

A little late to the party but it still might be useful.

  1. 转到 C:\Windows\System32\drivers\etc\hosts 并添加以下行:
  1. Go to C:\Windows\System32\drivers\etc\hosts and add this line:

127.0.0.1       local.example.com

  1. 在 React 项目中,添加一个 .env 文件:

HOST=local.example.com
PORT=3006

这篇关于如何将 React localhost (127.0.0.1:3000) 更新到另一个域 (local.example.com)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆