Skip to content

Enable loading price data over plain HTTP#44

Open
reddog wants to merge 1 commit intosimonw:mainfrom
reddog:enable-local-usage-when-fetching-price-data
Open

Enable loading price data over plain HTTP#44
reddog wants to merge 1 commit intosimonw:mainfrom
reddog:enable-local-usage-when-fetching-price-data

Conversation

@reddog
Copy link
Copy Markdown

@reddog reddog commented Dec 19, 2025

Switch method to load price data.

New solution pattern:

  • Code in index.html to load current prices switched from fetch to defining a script tag.
  • script tag is added after the DOM has loaded to ensure JS in index.html is available.
  • Handler function defined in index.html is called by the current prices JS script (current-v1.js)
  • Build script for prices data files enhanced to create a JavaScript version (in addition to the previous JSON version)
    • Current prices JS file augmented to call the handler defined in index.html

Processing follows this flow:

  • index.html is loaded in the browser
  • In JS in index.html, we wait until the DOM has loaded and then we:
    • Define logic to parse model prices (effectively this is unchanged)
    • Declare a handler to parse model prices
    • Create a script tag to load current-v1.js
  • Script current-v1.js will be loaded
    • current-v1.js is enclosed in a IIFE to protect itself and other scripts
    • Model price data is defined
    • Handler function defined in index.html is called to parse model prices - this continues the usual process flow.

Previous method uses JS fetch. This fails in Chrome when loading the file locally with a CORS Schema error.

Anticipated benefit is that users can run the web page locally for development / usage purposes.

Previously Chrome error was;

Access to fetch at 'file:///local-directory-path/current-v1.json' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: chrome, chrome-extension, chrome-untrusted, data, http, https, isolated-app.
image

…hrome over plain HTTP (for local development / usage purposes).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant