Stack 包含了两个前端应用: Console 和 OAuth 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.
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.
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.
Stack提供了 production 和 development 这两种模式的前端,可以通过环境变量 $NODE_ENV
来控制。编译命令为:
mage js:build
默认情况下,该 $NODE_ENV
为 production。本节笔记先按照 production 走,下一篇笔记再记录 development 的实践。
这里有个需要额外关注的,就是命令操作的步骤不能乱。基本上是 build frontend -> build stack -> stack start all -> browser。具体参考步骤如下:
$ ./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'
i. 访问 console
我是部署在腾讯云服务器上,所以浏览器访问URL要调整下IP。http://yourip:1885/console
ii. OAuth 认证
点击登录之后,会提示先认证,由于此前配置的 redirect-uri 是 localhost,因此需要手动调整下这个URL,将 localhost 替换为我们的 CVM IP。
先替换第一个localhost,之后填入用户名和密码。
iii. 登录 console
在重定向的第二次URL上将 localhost 调整为 CVM IP。