前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >The Things Network LoRaWAN Stack V3 学习笔记 2.7 编译运行 Web 前端

The Things Network LoRaWAN Stack V3 学习笔记 2.7 编译运行 Web 前端

作者头像
twowinter
修改2023-09-21 16:38:18
4870
修改2023-09-21 16:38:18
举报
文章被收录于专栏:twowintertwowinter

1 Stack 前端简介

Stack 包含了两个前端应用: ConsoleOAuth Provider

Both applications use React as frontend framework. The console and oauth packages of the backend expose their respective web servers and handle all logic that cannot be done in the browser. Otherwise both applications are single page applications (SPA) that run entirely in the browser.

Console

The Console is the official management application of the stack. It can be used to register applications, end devices or gateways, monitor network traffic, or configure network related options, among other things. The console uses an OAuth access token to communicate with the stack.

OAuth

The OAuth app provides the necessary frontend for the OAuth provider of the stack. It is used e.g. to display the authorization screen that users get prompted with when they want to authorize a third-party app to access the stack.

2 编译 Stack 前端

Stack提供了 production 和 development 这两种模式的前端,可以通过环境变量 $NODE_ENV 来控制。编译命令为:

代码语言:javascript
复制
mage js:build

默认情况下,该 $NODE_ENV 为 production。本节笔记先按照 production 走,下一篇笔记再记录 development 的实践。

3 总体操作流程

这里有个需要额外关注的,就是命令操作的步骤不能乱。基本上是 build frontend -> build stack -> stack start all -> browser。具体参考步骤如下:

  1. ./mage init
  2. ./mage js:build
  3. go build ./cmd/ttn-lw-stack
  4. Identity Server 配置
代码语言:javascript
复制
$ ./ttn-lw-stack is-db init
$ ./ttn-lw-stack is-db create-admin-user --id admin --email admin@localhost
$ ./ttn-lw-stack is-db create-oauth-client --id console --name "Console" --owner admin --secret console --redirect-uri 'https://localhost:8885/console/oauth/callback' --redirect-uri 'http://localhost:1885/console/oauth/callback' --redirect-uri '/console/oauth/callback'
  1. ./cmd/ttn-lw-stack start all
  2. 如果是在本地上跑的话,那么直接浏览器访问 http://localhost:1885/console

4 部署在CVM上的操作

i. 访问 console

我是部署在腾讯云服务器上,所以浏览器访问URL要调整下IP。http://yourip:1885/console

ii. OAuth 认证

点击登录之后,会提示先认证,由于此前配置的 redirect-uri 是 localhost,因此需要手动调整下这个URL,将 localhost 替换为我们的 CVM IP。

先替换第一个localhost,之后填入用户名和密码。

iii. 登录 console

在重定向的第二次URL上将 localhost 调整为 CVM IP。

END

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 1 Stack 前端简介
  • Console
  • OAuth
  • 2 编译 Stack 前端
  • 3 总体操作流程
  • 4 部署在CVM上的操作
  • END
相关产品与服务
云服务器
云服务器(Cloud Virtual Machine,CVM)提供安全可靠的弹性计算服务。 您可以实时扩展或缩减计算资源,适应变化的业务需求,并只需按实际使用的资源计费。使用 CVM 可以极大降低您的软硬件采购成本,简化 IT 运维工作。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档