修改Web Crypto API 在 HTTP 环境下不可用的问题,自动降级
- HTTPS/localhost :正常启用加密 - HTTP(非 localhost) :自动禁用加密,以明文方式通信
This commit is contained in:
@@ -3,10 +3,10 @@
|
||||
* Handles auth tokens, request/response encryption, snake_case→camelCase conversion.
|
||||
*/
|
||||
|
||||
import { encrypt, decrypt } from './crypto';
|
||||
import { encrypt, decrypt, isCryptoAvailable } from './crypto';
|
||||
|
||||
const BASE_URL = import.meta.env.VITE_API_BASE || 'http://localhost:8000';
|
||||
const USE_ENCRYPTION = !!import.meta.env.VITE_ENCRYPTION_KEY;
|
||||
const USE_ENCRYPTION = !!import.meta.env.VITE_ENCRYPTION_KEY && isCryptoAvailable();
|
||||
|
||||
interface RequestOptions {
|
||||
method?: string;
|
||||
|
||||
Reference in New Issue
Block a user