tints.dev icon indicating copy to clipboard operation
tints.dev copied to clipboard

API throws CORS error

Open endigo9740 opened this issue 3 years ago • 9 comments

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

endigo9740 avatar Sep 01 '22 21:09 endigo9740

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

SimeonGriggs avatar Sep 02 '22 05:09 SimeonGriggs

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.

endigo9740 avatar Sep 02 '22 18:09 endigo9740

same problem here..

gochitashvili avatar Sep 24 '22 06:09 gochitashvili

Is this still being looked into?

Ushie avatar Jan 30 '23 15:01 Ushie

+1 Waiting for this

bdcorps avatar Mar 21 '23 13:03 bdcorps

It will be VERY useful!

Steffi3rd avatar Nov 08 '23 15:11 Steffi3rd

Up

antoinebarbier022 avatar Mar 05 '24 17:03 antoinebarbier022

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.

endigo9740 avatar Mar 05 '24 17:03 endigo9740

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!

yabdab avatar Mar 26 '24 19:03 yabdab