question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add an option to disable CORS proxy

See original GitHub issue

Parchment automatically uses a proxy to download the story file if it detects that it’s not on the same domain. There are two cases where the proxy makes things worse rather than better:

  1. The file is on a different domain, but the server sets the correct CORS headers so it works without the proxy. The file might be inaccessible to the proxy (localhost, internal network etc.)
  2. The URL is a data URL (data:...)

I’ve been able to get around it with default_story: "data:text/javascript,processBase64Zcode('....'); // .js" which tricks Parchment into thinking that it’s a legacy .js file, but that’s a very hacky solution.

Arguably case 2 is a bug and it should detect data URLs, but for case 1 we’d need either that setting the proxy URL option to null would disable it altogether, or a separate setting that disables the proxy. Preferably with options auto-detection (current behavior), always enabled or always disabled. HugoJS has this setting:

// use a CORS proxy to load game files?
// "always" (or true), "never" (or false), or "auto".
// The "auto" option uses proxy only if the story URL points to another domain.
use_proxy: "auto"

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
curiousdanniicommented, Apr 10, 2022

If you set

parchment_options = {auto_launch: 0}

Then Parchment won’t launch automatically. You can then call parchment.load() passing a Uint8Array and a format name:

parchment.load(data, 'glulx')

I think your concerns here have basically been handled by now, but if you have any more just make a new issue.

0reactions
juhanacommented, Jun 30, 2022

Thanks, that’ll certainly make things more straightforward!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Adding CORS support to an API proxy | Apigee Edge
You can add CORS support to an API proxy by attaching an "Add CORS" policy to the API proxy when you create it....
Read more >
Avoiding CORS Errors on Localhost (in 2020) | by Andy Potts
1. Use the proxy setting in Create React App · 2. Disable CORS in the browser · 3. Use a proxy to avoid...
Read more >
garmeeh/local-cors-proxy: Simple proxy to bypass CORS issues.
Simple proxy to bypass CORS issues. This was built as a local dev only solution to enable prototyping against existing APIs without having...
Read more >
How and Why You Should Avoid CORS in Single Page Apps
The example below shows how you can add proxy configuration in the Webpack dev server. };
Read more >
Why is an OPTIONS request sent and can I disable it?
Quickest fix is definitely to just use Access-Control-Max-Age on CORS responses so it only gets requested once. – Ian. Jul 18, 2020 at...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found