CSP-compatible output via external script for build-docs
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 25.9k
- Forks
- 2.4k
- Avg merge
- 13h 10m
- Merged PRs (30d)
- 4
Description
When using @redocly/cli build-docs to generate a static HTML file, ReDoc injects the entire rendered state as an inline <script> block:
<script>
const __redoc_state = { ... }; // entire OpenAPI spec serialized here
var container = document.getElementById('redoc');
Redoc.hydrate(__redoc_state, container);
</script>
This inline script violates Content Security Policy (CSP) directives that disallow 'unsafe-inline' for script-src. In many enterprise setups, the CSP is enforced by an API gateway or reverse proxy and cannot be modified by the application team, making it impossible to whitelist inline scripts.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running @redocly/cli build-docs and inspect how the generated static HTML embeds the serialized OpenAPI state and hydration script. Trace the build-docs output path and determine how an external script could replace the inline block. Done means the generated HTML works without requiring 'unsafe-inline' in script-src.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- cli, documentation
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Needs clarification
- Newbie friendliness
- 45/100