Skip to content

Example code for doing CORS requests to eLabFTW API

License

Notifications You must be signed in to change notification settings

elabftw/elabapi-javascript-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

eLabFTW Javascript demo

Description

This example web page shows how to interact with an eLabFTW server through javascript. It requires configuring correctly the eLabFTW service to allow CORS requests.

Configuration

In the docker-compose file (/etc/elabftw.yml by default), add this:

# here the value must the of the service doing the request
- ALLOW_ORIGIN=http://localhost:8087
# comma separated list of methods (use GET, POST, PATCH, DELETE for full api access)
- ALLOW_METHODS=GET
- ALLOW_HEADERS=Content-Type, Authorization

Restart the service (elabctl restart).

Usage

Run a local server with:

git clone https://github.com/elabftw/elabapi-javascript-example
cd elabapi-javascript-example
docker run --rm -v ${PWD}:/usr/share/nginx/html -p 8087:80 -d nginx

Modify the javascript code to point to your server with a valid API Key.

Go to http://localhost:8087 to try it out!

About

Example code for doing CORS requests to eLabFTW API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages