From cf11cc2d3cb9c7ebaa612cf4728aec4ec81cdc54 Mon Sep 17 00:00:00 2001 From: "thomashii@dukefirehawk.com" Date: Mon, 13 Nov 2023 10:08:33 +0800 Subject: [PATCH] Updated Hot --- packages/hot/CHANGELOG.md | 2 +- packages/hot/README.md | 27 +++++++++++++++++++++++++++ packages/hot/pubspec.yaml | 2 +- 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/packages/hot/CHANGELOG.md b/packages/hot/CHANGELOG.md index 97e0a368..bab11244 100644 --- a/packages/hot/CHANGELOG.md +++ b/packages/hot/CHANGELOG.md @@ -3,7 +3,7 @@ ## 8.1.0 * Updated `vm_service` to 13.0.0 -* Added configurable HTTP response header +* Updated README ## 8.0.0 diff --git a/packages/hot/README.md b/packages/hot/README.md index f06952e1..242fd99c 100644 --- a/packages/hot/README.md +++ b/packages/hot/README.md @@ -77,3 +77,30 @@ Future createServer() async { return app; } ``` + +## Customising Response Header + +The following code snippet removes `X-FRAME-OPTIONS` and adds `X-XSRF-TOKEN` to the response header. + +```dart +import 'dart:io'; +import 'package:angel3_hot/angel3_hot.dart'; +import 'server.dart'; + +void main() async { + var hot = HotReloader(createServer, [ + Directory('src'), + 'server.dart', + // Also allowed: Platform.script, + Uri.parse('package:angel3_hot/angel3_hot.dart') + ]); + var http = await hot.startServer('127.0.0.1', 3000); + + // Remove 'X-FRAME-OPTIONS' + http.defaultResponseHeaders.remove('X-FRAME-OPTIONS', 'SAMEORIGIN'); + + // Add 'X-XSRF_TOKEN' + http.defaultResponseHeaders.add('X-XSRF-TOKEN', + 'a591a6d40bf420404a011733cfb7b190d62c65bf0bcda32b57b277d9ad9f146e'); +} +``` diff --git a/packages/hot/pubspec.yaml b/packages/hot/pubspec.yaml index 178d09c1..0990db99 100644 --- a/packages/hot/pubspec.yaml +++ b/packages/hot/pubspec.yaml @@ -6,7 +6,7 @@ repository: https://github.com/dukefirehawk/angel/tree/master/packages/hot environment: sdk: '>=3.0.0 <4.0.0' dependencies: - angel3_framework: ^8.0.0 + angel3_framework: ^8.2.0 angel3_websocket: ^8.0.0 belatuk_html_builder: ^5.0.0 charcode: ^1.3.0