# 出现CSP错误时的处理方法

在网站安装标签并[确认标签触发](https://helps.ptengine.com/cn/faq/start-guide/check-tag-firing)时，如果出现 Content Security Policy（CSP）错误，请参考本文，将 Ptengine 的域名添加到白名单中。

错误页面示例

<figure><img src="/files/mOiM3CHWQhpdILR9NO31" alt="CSP错误页面（控制台）"><figcaption></figcaption></figure>

<figure><img src="/files/VR4C7SqJnVlHBWYLT1g6" alt="CSP错误页面（网络标签）"><figcaption></figcaption></figure>

## 仅设置了 `default-src` 的情况 <a href="#default-src" id="default-src"></a>

需要同时添加 `unsafe-inline`、`*.ptengine.jp` 和 `*.ptengine.com` 三项。

```
<meta http-equiv="Content-Security-Policy" content="default-src 'self' 'unsafe-inline' *.ptengine.jp *.ptengine.com">
```

## 按媒体类型分别设置 CSP 的情况 <a href="#per-media" id="per-media"></a>

请参考以下表格进行设置。

| 媒体类型        | 策略                                                    |
| ----------- | ----------------------------------------------------- |
| script-src  | `'self' 'unsafe-inline' *.ptengine.jp *.ptengine.com` |
| style-src   | `'self' 'unsafe-inline' *.ptengine.jp *.ptengine.com` |
| connect-src | `*.ptengine.jp *.ptengine.com`                        |
| img-src     | `*.ptengine.jp *.ptengine.com`                        |
| frame-src   | `*.ptengine.jp *.ptengine.com`                        |

```
<meta http-equiv="Content-Security-Policy" content="default-src 'self' *.mydomain.com; script-src 'self' 'unsafe-inline' *.ptengine.jp *.ptengine.com; style-src 'self' 'unsafe-inline' *.ptengine.jp *.ptengine.com; connect-src 'self' wss://*.mydomain.com *.ptengine.jp *.ptengine.com; img-src 'self' *.ptengine.jp *.ptengine.com; font-src 'self' * data:; frame-src 'self' *.ptengine.jp; worker-src 'self' blob:">
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://helps.ptengine.com/cn/faq/others/csp-policy.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
