开发服务器返回错误代码 403 react native

编程入门 行业动态 更新时间:2024-10-25 08:26:27
本文介绍了开发服务器返回错误代码 403 react native的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

按照

---编辑---

问题可能是 McAfee 正在使用 8081 端口.所以我更新了 server.js 以在 8088 上运行开发端口,现在当我浏览 localhost:8088/index.android.bundle?platform=android 我可以看到 JS 加载.

但是我如何让 android 使用这个地址而不是默认的 **10.0.2.2:8081?** 我找到了一个包含 10.0.2.2 路径的文件 AndroidInfoHelpers.java 但不确定是否这就是作为 JAVA 文件的方式,我可能需要重新编译整个程序.应该有一种更简单的方法可以让 Android 应用程序为开发服务器使用不同的端口.

此外,当我执行 react-native run-android 时,获得输出的第一行显示JS 服务器无法识别.. 继续构建",这可能是在喊同样的事情.>

解决方案

A) 为开发服务器设置新端口 用户命令react-native start --port=8088 或 yourproject ode_moduleseact-nativelocal-cliserverserver.js设置可用端口说 8080现在使用 react-native start 在 8080 上启动服务器B) 现在要在模拟器和开发服务器之间建立通信,请使用以下命令adb -s 模拟器 -5554 反向 tcp:8088 tcp:8088i) 5554 => 模拟器端口(adb devices 命令会告诉您模拟器端口,但如果此命令不起作用,则在 中设置路径 C:/../android-sdk/platform-tools>Path 环境变量 )ii) 8088 =>服务器端口

C) 运行命令 react-native run-android

D) 按照以下步骤在模拟器中更新 Dev 服务器路径

i) Windows 的 Ctrl + M 打开模拟器的开发菜单.ii) 单击开发设置 III) 在 Debugging 下选择 Debug server host &设备端口 IV) 输入您的应用程序的 url 和端口为 10.0.2.2:8088

Followed the steps here to try react-native android on a windows box.

  • On a separate prompt I executed react-native start which is running fine
  • Started the AVD from AVD Manager
  • Executed react-native run-android
  • BUILD SUCCESSFUL Total time: 27.632 secs Starting the app on emulator-5554 (D:softwareAndroidandroid-sdk/platform-tool s/adb -s emulator-5554 shell am start -n com.awesomeproject/.MainActivity)... Starting: Intent { cmp=com.awesomeproject/.MainActivity }

  • Executed react-native run-android on a separate console from within same folder
  • But I see an error which I'm having hard time to resolve. Please suggest resolution.

    ---EDIT---

    Possibly the issue is that 8081 port is in use by McAfee. So I updated the server.js to run dev port on 8088 and now when I browse localhost:8088/index.android.bundle?platform=android I can see JS loading.

    But how do I make android use this address instead of default **10.0.2.2:8081?** I found a file AndroidInfoHelpers.java which contains that 10.0.2.2 path but not sure if that's the way as being a JAVA file I possibly need to recompile whole program. There should be a simpler way to point android app to use a different port for dev server.

    Also, when I execute react-native run-android the first line that gets output says "JS Server not recognized.. Continuing with the build" which likely is shouting the same thing.

    解决方案

    A) Set the new port for dev server User command react-native start --port=8088 or yourproject ode_moduleseact-nativelocal-cliserverserver.js to set the the available port say 8080 now use react-native start to start server on 8080 B) Now to establish communication between emulator and dev server, use below command adb -s emulator -5554 reverse tcp:8088 tcp:8088 i) 5554 =>emulator port (adb devices command will tell you emulator port but if this command is not working then set the path C:/../android-sdk/platform-tools in Path environemnt variable ) ii) 8088 =>server port

    C) run the command react-native run-android

    D) Follow below steps updating Dev server path in emulator

    i) Ctrl + M for windows to open your dev menu for the emulator. ii) Click Dev Settings III) Under Debugging select Debug server host & port for device IV) Enter the url and port for your application as 10.0.2.2:8088

    更多推荐

    开发服务器返回错误代码 403 react native

    本文发布于:2023-11-24 10:34:04,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1624856.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:错误代码   服务器   react   native

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!