Add an option to disable CORS proxy
See original GitHub issueParchment 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:
- 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.)
- 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:
- Created 3 years ago
- Comments:11 (11 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
If you set
Then Parchment won’t launch automatically. You can then call
parchment.load()
passing a Uint8Array and a format name:I think your concerns here have basically been handled by now, but if you have any more just make a new issue.
Thanks, that’ll certainly make things more straightforward!