Local development
If you're using the HTML or JavaScript API, it's not possible to add the Canva Button to an HTML file on your local machine and open that file in a web browser. If you do this, you'll encounter a Forbidden (403) error.
This is because Canva expects requests to come from:
- canva.com
- localhost
- a domain on Canva's allowlist
This guide explains how to develop locally by serving an HTML file via localhost
.
Step 1: Install http-server
http-server
is "a simple, zero-configuration command-line HTTP server." You can use it to make a file (or a directory of files) available via localhost
.
You can install http-server
via npm or Homebrew.
npm
npm install http-server --global
Homebrew
brew install http-server
Step 2: Navigate into the project's directory
Use the cd
command to navigate into the directory that contains the HTML file:
cd [dir_path]
Step 3: Start the local server
To start the local server, run the http-server
command:
http-server
By default, the local server becomes available at http://localhost:8080.