Skip to content

Commit

Permalink
ビルド時にリクエスト先を指定
Browse files Browse the repository at this point in the history
  • Loading branch information
narumincho committed Jan 22, 2024
1 parent 3143ea6 commit 6327acf
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/deploy_to_cloudflare_pages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ jobs:
flutter-version: ${{ steps.fvm-config-action.outputs.FLUTTER_VERSION }}
channel: ${{ steps.fvm-config-action.outputs.FLUTTER_CHANNEL }}
cache: true
- run: flutter build web
- run: flutter build web --dart-define=ORIGIN=https://definy.deno.dev
- name: Deploy to Cloudflare Pages
uses: cloudflare/pages-action@1
with:
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
projectName: definy
directory: ./build/web/
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ deno run --allow-run --allow-read ./script/typeCheck.ts

## フォルダとファイルの説明

- `/.github/workflows/pull_request.yml`: Pull Request
- `.github/workflows/pull_request.yml`: Pull Request
したときに実行されるテストの処理が書かれている
- `/.vscode`: VSCode 向けの設定
- `/assets`: スタティックなファイルが置かれている
- `.vscode`: VSCode 向けの設定
- `assets`: スタティックなファイルが置かれている
- `local.sqlite`, `local.sqlite-shm`, `local.sqlite-wal`
ローカルで開発するときに使うデータベースのファイル
6 changes: 6 additions & 0 deletions lib/env.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// ignore_for_file: do_not_use_environment

const origin =
String.fromEnvironment('ORIGIN', defaultValue: 'http://localhost:8080');

final originUri = Uri.parse(origin);
5 changes: 3 additions & 2 deletions lib/widget/input_account_code_and_display_name.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:definy/env.dart';
import 'package:definy/graphql/api.dart';
import 'package:definy/graphql/type.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -54,7 +55,7 @@ class _InputAccountCodeAndDisplayNameState
});
Api.accountByCode(
code: accountCode,
Uri.parse('http://127.0.0.1:8000/graphql'),
originUri,
null,
).then(
(response) {
Expand Down Expand Up @@ -149,7 +150,7 @@ class _InputAccountCodeAndDisplayNameState
});
try {
final totpKey = (await Api.createTotpKey(
Uri.parse('http://localhost:8000'),
originUri,
null,
))
.createTotpKey;
Expand Down
5 changes: 3 additions & 2 deletions lib/widget/input_totp_code.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:definy/env.dart';
import 'package:definy/graphql/api.dart';
import 'package:definy/graphql/type.dart';
import 'package:definy/widget/input_account_code_and_display_name.dart';
Expand Down Expand Up @@ -31,7 +32,7 @@ class _InputTotpCodeState extends State<InputTotpCode> {
final totpCode = TotpCode.fromString(_totpCodeController.text);
if (totpCode != null) {
Api.createAccount(
Uri.parse('http://localhost:8000'),
originUri,
null,
totpCode: totpCode,
displayName: widget.beforeResult.displayName,
Expand Down Expand Up @@ -89,7 +90,7 @@ class _InputTotpCodeState extends State<InputTotpCode> {
_requestState = const _RequestStateRequesting();
});
final response = await Api.createAccount(
Uri.parse('http://localhost:8000'),
originUri,
null,
totpKeyId: widget.beforeResult.totpKey.id,
totpCode: totpCode,
Expand Down

0 comments on commit 6327acf

Please sign in to comment.