Library
Developer Home
FD1 Client Protocol
Home
Concepts
Reading Data
Writing Data
Protocol Defined
Servers
Connect & Authenticate
Proxies & Tunnels
Webhooks & FirehosesProgramming Support
Logging
Minor Facts
State Facts
Response Format
How To Guides
eCommerce Sites
Custom Point of Sale
Customer Access
Bulk Downloads
Major APIs / Endpoints
All Endpoints
Products
Sales
SalesBuilder
Session
Get Attribute
Sale Capture
General Purpose
Data Capture
Devices
Barcode Scanners
Eftpos
IoT Sensors
Power Outlets
Printing
Scales
Security Cameras
Purchasing / Supply Side
Purchase Orders
Invoices
Invoice Payments
Document Capture
Rare APIs / Endpoints
SSL Certificates
API Key Management
Diagnositics
PosGreen
Server to Client Messages
Overview
Resources / Objects
Purchase Order
Invoice Payable
Invoice Payment
Product
Supplier
Location
Sale Lines
Sale Delivery Details
Sales
Price Maps
Employees
Carriers
Payments
Product Kits
Department 1
Customers
Webhooks & Firehoses
Proxies are optional, nothing on this page is required in order to use FD1 Protocol.
Proxies & Tunnels
In most circumstances your client programs access Fieldpine directly, providing security requirements and dealing with browser requirements.
Fieldpine Server | ⇄ | Internet | ⇄ | FD1 Client Protocol | ⇄ | Your App |
It is possible to run a local proxy in a trusted environment, client side, as shown below
Fieldpine Server | ⇄ | Internet | ⇄ | Client Side Proxy | ⇄ | FD1 Client Protocol | ⇄ | Your App |
Running a proxy has the following attributes
- It can simplify development, even if just initially, as it can hide complexity around CORS and required headers
- Running a caching proxy can improve performance by keeping data closer to the end consumer
- Be careful with security of your proxy server - anybody that can connect to your server is implicitly authorised
- Never expose your proxy to the internet without security controls
Simple Proxy
To create a simple proxy....
- Download and install Deno (Deno Install) Tip - its really just a single program
-
Create a file "fieldpine_proxy.bat" containing the following lines, replacing values as required
set PROXY_API_KEY=ABCsjshsh204757ghg set PROXY_HOST=https://retailer-server.xyz deno run --allow-net --allow-env fieldpine_proxy.ts
-
Create a file "fieldpine_proxy.ts" containing the following lines
Deno.serve({ port: 8080 }, async (request) => { const { pathname, search } = new URL(request.url) const url = new URL('.' + pathname, Deno.env.get('PROXY_HOST')) url.search = search const headers = new Headers(request.headers) headers.set('Host', url.hostname) headers.set('x-api-key', Deno.env.get('PROXY_API_KEY')) // If CORS breaking required, uncomment and edit next line // headers.set("Access-Control-Allow-Origin", allowedOrigins); return fetch(url, { method: request.method, headers, body: request.body, redirect: 'manual', }) })
- Run the proxy by running fieldpine_proxy.bat
-
In your client programs, call your proxy.
fetch("http://127.0.0.1:8080/fd1/...") ....
- See the Deno help pages for how to add https support.
Caching Proxy
A caching proxy can improve performance