Skip to content

Commit 024eca0

Browse files
committed
Added clarifications about artifacts loaded from the filesystem.
1 parent 7878e24 commit 024eca0

2 files changed

Lines changed: 23 additions & 2 deletions

File tree

README.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ docker run --rm -p 5173:5173 -v $(pwd):/w -w /w claudiombsilva/claude-artifact-r
3939
- [If you want to just run an Artifact](#if-you-want-to-just-run-an-artifact)
4040
- [If you want to build an Artifact](#if-you-want-to-build-an-artifact)
4141
- [If you want to view a previously built Artifact](#if-you-want-to-view-a-previously-built-artifact)
42+
- [Caveats for opening a single-file build directly from the filesystem](#caveats-for-opening-a-single-file-build-directly-from-the-filesystem)
4243
- [If you want to create a full project for one or more Artifacts](#if-you-want-to-create-a-full-project-for-one-or-more-artifacts)
4344
- [Using Docker instead of npx](#using-docker-instead-of-npx)
4445
- [Limitations](#limitations)
@@ -146,7 +147,7 @@ If you don't have an Artifact to run yet, and just want to try out the project,
146147

147148
The tool outputs an HTML file in your current directory, which contains all the code for running the application (HTML, CSS, JavaScript and a *favicon*).
148149

149-
This file can be deployed to any **static** web hosting service or cloud platform.
150+
This file can be deployed to any **static** web hosting service or cloud platform, and **sometimes** it can even be opened directly from the filesystem (double-click the HTML file or open the URL `file://path/to/file.html`), but with some caveats (see below).
150151

151152
### If you want to view a previously built Artifact
152153

@@ -162,6 +163,25 @@ There are two build types, with different preview methods:
162163
- `npx run-claude-artifact view artifact-directory-name` (serve the directory)
163164
- The tool launches a temporary web server and opens your browser. Press `Ctrl+C` to stop.
164165

166+
#### Caveats for opening a single-file build directly from the filesystem
167+
168+
There are always going to be some artifacts that won't be able to run correctly (or at all) when opened directly from the file system, but that is a fundamental browser restriction, not something the tool can solve.
169+
170+
A page opened as `file://` isn’t treated like a normal website. Browsers put it in a kind of sandbox, because a local file could otherwise snoop around your machine.
171+
172+
Succintly:
173+
174+
- Remote resource loading? **Often allowed.**
175+
- Remote API calls? **Allowed only if CORS says yes.**
176+
- Local-file cross-access? **Blocked.**
177+
178+
> Please make sure your artifact isn't being **blocked** by the browser's security policy, **before submitting a bug report**.
179+
180+
The best way to avoid issues and view a file locally is to place your `index.html` in a blank directory and run either:
181+
182+
* `npx run-claude-artifact view <your-directory>`, or
183+
* `npx serve <your-directory>`
184+
165185
### If you want to create a full project for one or more Artifacts
166186

167187
Instead of just viewing or building an Artifact, you may create a full project for further development, and optionally push it to your own Git repository.

npx/run-claude-artifact.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@ npx run-claude-artifact build my-app.tsx --deploy-dir /var/www # Custom output
133133
npx run-claude-artifact create my-app.tsx --remote <url> --push # Create + git + push
134134
135135
Notes:
136-
- Built artifacts require a web server to run correctly
136+
- Built artifacts may require a web server to run correctly, depending on what the artifact does and
137+
the browser's security policy. See the GitHub repo's README.md for more details.
137138
- For multi-file artifacts, specify the directory, not the HTML file
138139
- --remote and --push require 'create' subcommand
139140
- Default deployment: single file to CWD, multi-file to CWD/filename/dist

0 commit comments

Comments
 (0)