我正在开发一个 Chrome 扩展,其manifest.json 文件如下:
{
"manifest_version": 3,
"name": "JIRA bug Recorder",
"description": "",
"background": { "service_worker": "background.bundle.js" },
"action": {
"default_popup": "popup.html",
"default_icon": "Icon32.png"
},
"icons": {
"32": "Icon32.png",
"128": "Icon128.png"
},
"permissions": [
"activeTab",
"scripting",
"storage",
"unlimitedStorage",
"contextMenus",
"webNavigation",
"tabs",
"desktopCapture"
],
"host_permissions": ["<all_urls>"],
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": ["pageContent.bundle.js"]
}
]
}
Run Code Online (Sandbox Code Playgroud)
当我单击扩展程序图标以显示 popup.html 时,我在扩展程序上收到以下错误。
我注意到,如果我从 manifest.json 中删除host_permissions和字段,错误就会消失。content_scripts
我不知道为什么,因为我的脚本都没有设置跨站点 cookie,包括pageContent.bundle.js.
有谁知道如何解决或抑制这个问题?
谢谢,
我试图在 AuthModule 中加载“process.env.AUTH_SECRET”,但它给了我未定义的错误“错误:secretOrPrivateKey 必须有一个值”。
我确实在 AppModule 中设置了“isGlobal: true”,并且它能够很好地读取“process.env.MONGO_URL”。
我还安装了 dotenv,如果我这样做的话,它读起来很好:
import * as dotenv from 'dotenv';
dotenv.config();
export const jwtConstants = {
secret: process.env.AUTH_SECRET,
};
Run Code Online (Sandbox Code Playgroud)
但我宁愿以“NestJs”方式进行操作,因为文档说添加 isGlobal 应该使 env 可用于所有其他模块。
auth.module.ts
import { Module } from '@nestjs/common';
import { AuthService } from './auth.service';
import { UserModule } from '../user/user.module';
import { PassportModule } from '@nestjs/passport';
import { LocalStrategy } from './local.strategy';
import { JwtModule } from '@nestjs/jwt';
@Module({
imports: [
UserModule,
PassportModule,
JwtModule.register({
secret: process.env.AUTH_SECRET, //Cannot read this. …Run Code Online (Sandbox Code Playgroud) User我有一个从到 的OneToMany 关系Message。
当我使用消息插入注册用户时,它将用户添加到表中User,并将消息添加到Message表中并userId指向用户的 id。
这是使用以下设置自动完成的。
User实体:
@Entity()
export class User {
@PrimaryGeneratedColumn()
id: number;
@Column()
name: string;
@Column()
email: string;
@JoinTable()
@OneToMany((type) => Message, (message) => message.user, {
cascade: true,
})
messages: Message[];
}
Run Code Online (Sandbox Code Playgroud)
Message实体:
@Entity()
export class Message {
@PrimaryGeneratedColumn()
id: number;
@Column()
text: string;
@ManyToOne((type) => User, (user) => user.messages, { eager: true })
user: User[];
}
Run Code Online (Sandbox Code Playgroud)
如果我想通过以下方式查找来自用户的所有消息userId:
const existing_msgs = await this.messageRepository.find({
where: …Run Code Online (Sandbox Code Playgroud)