Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature request] Get a list of providers without HTTP request #126

Open
Ningensei848 opened this issue Jun 22, 2023 · 0 comments
Open

[Feature request] Get a list of providers without HTTP request #126

Ningensei848 opened this issue Jun 22, 2023 · 0 comments

Comments

@Ningensei848
Copy link

Environments

  • @remark-embedder/transformer-oembed version: v3.0.0
  • node version: v18.16.0
  • npm version: v9.5.0

Relevant code or config:

async function getProviders(): Promise<Providers> {
if (!getProviders.cache) {
const res = await fetch('https://oembed.com/providers.json')
getProviders.cache = (await res.json()) as Providers
}
return getProviders.cache
}

What you did:

  • I tried to use @remark-embedder/core (with @remark-embedder/transformer-oembed) as a remark plugin for MDX v2.
  • I was going to use GitHub to manage the markdown and other static files, and Cloudflare Pages to build and deploy them.

What happened:

  • ECONNRESET happend.
Error: MDX compilation failed for file "/opt/buildhome/repo/content/docs/index.mdx"
--
Cause: request to https://oembed.com/providers.json failed, reason: Client network socket disconnected before secure TLS connection was established
Details:
{
  "code": "ECONNRESET",
  "path": null,
  "host": "oembed.com",
  "port": 443,
  "errno": "ECONNRESET",
  "type": "system"
}

Reproduction repository:

  • N/A

Problem description:

Presumably, the Cloudflare Pages build environment is placed under their proxy environment and HTTP requests to the outside world are closed.

Suggested solution:

There should be an alternative way to obtain JSON data without going through communication with the outside world; i.e., the following two solutions could be considered:

  1. Write provider information obtained from URL as Object in the code.
  2. Provide an option to load a pre-prepared JSON file.

The former method is NOT recommended because the amount of code becomes bloated, and the time required to update information increases.
Therefore, the latter method is recommended, as it seems to solve the problem without burdening the developer.

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

No branches or pull requests

1 participant