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

API throws CORS error #21

Open
endigo9740 opened this issue Sep 1, 2022 · 9 comments
Open

API throws CORS error #21

endigo9740 opened this issue Sep 1, 2022 · 9 comments

Comments

@endigo9740
Copy link

Hey, first off this is great! I've attempted to build something like this and really be struggling. The colors end up uneven or in the wrong oder. However, I'm running into cross-origin (CORS) when I attempt to use your API.

Using the example endpoint here:
https://www.simeongriggs.dev/using-the-tailwind-css-palette-generator-and-api

fetch('https://tailwind.simeongriggs.dev/api/brand/2522FC')
    .then((response: any) => response.json())
    .then((json: any) => console.log(json));

Here's the error received:

Screen Shot 2022-09-01 at 4 11 40 PM

@SimeonGriggs
Copy link
Owner

I see!

Haven't given any consideration to fetching client side like this before and the implication to throwing the doors open on CORS ... let me do some research and get back to you

@endigo9740
Copy link
Author

No worries Simeon. I'm going a different direction with my project, so I won't be using this for now. However, I thought you might want a heads up. No rush on my behalf needed. Thanks for the quick response though.

@gochitashvili
Copy link

same problem here..

@Ushie
Copy link

Ushie commented Jan 30, 2023

Is this still being looked into?

@bdcorps
Copy link

bdcorps commented Mar 21, 2023

+1 Waiting for this

@Steffi3rd
Copy link

It will be VERY useful!

@antoinebarbier022
Copy link

Up

@endigo9740
Copy link
Author

endigo9740 commented Mar 5, 2024

Since I keep getting pinged on this one, I thought I'd at least share the solution we've gone with in the meantime:

https://gka.github.io/chroma.js/

This is an extremely tiny dependency that can do a whole host of things with colors. The .scale() feature is especially nice in regards to creating color ramps like we need for Tailwind. We're making heavy use of it for the open source theme generator I'm currently building for my UI library.

This is more of a "build it yourself" option, but just thought I'd share in case it helps others out.

@yabdab
Copy link

yabdab commented Mar 26, 2024

Confused as to how to use this "API" if it cannot be called from outside servers? Hopefully it can be made useful some day.
Tints.dev works great though, just wish the "API" was able to use no-cors

I ended up creating a PHP script, that used curl to query the tints.dev Palette API endpoint , on my server.
I then use that local endpoint instead. Works great!

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

8 participants