- Notifications
You must be signed in to change notification settings - Fork16
[WIP] generate a sharable image/png when copying#170
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
The API even works well with Python requests: I noticed that in no-CORS mode, the request type is opaque, so I can't get the response body (seethis answer). I forced no-CORS mode because the hostname @lihebi Do you have any idea or suggestion with it? |
}; | ||
const res = await fetch("http://localhost:3099/api/cook", requesOptions); | ||
const pic = await res.blob(); | ||
// navigator.clipboard.write([new ClipboardItem({ "image/png": pic })]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
method: "POST", | ||
headers: { "Content-Type": "application/json" }, | ||
body: JSON.stringify({ code: pod.content }), | ||
mode: "no-cors" as RequestMode, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
CORS seems problematic. Let's add an Nginx route.
# nginx.conflocation /carbon { rewrite ^/carbon(.*)$$1break; proxy_pass http://carbon:3000;}
and in compose.yml, add a container:
carbon: image: local/carbonara
The request URL will behttp://localhost/carbon/api/cook
Uh oh!
There was an error while loading.Please reload this page.
I use this API ofcarbon:https://github.com/petersolopov/carbonara
Notice that
localhost
doesn't allowCROS, we can't send a request ofapplication/json
payload tolocalhost:3099/api/cook
, the actual request body is intext/plain
format. So you may need to skip the content type checking by deleting this linehttps://github.com/petersolopov/carbonara/blob/master/src/utils.js#L118, and then run the deployment command of this api by:To test if the api running normally, run a
cURL
command:Now, the fetch request can be viewed with correct preview in devtools, I just wonder how to take it out.