LocalAI
LocalAI copied to clipboard
Cors Problem Using JS Axios
Excuse me, hello!
I'm facing a issue using a JS front-end to connect to the LocalAI API. I saw the issue about the Cors fix, but it still doesn't work.
I also tried to disable cors in axios, but with that option i cant retrieve the body response.
Axios Function(i'm a newbie, please be nice <3)
function StartShowPayload() { const [payload, setPayload] = useState([]); useEffect(async () => { axios.get("http://192.168.2.32:8080/models", ).then((res) => { const threads = res; setPayload(threads); }); }, []);
LocalAI API is running in another computer inside my local network, Thank you so much for your time! :)
You can set corsAllowedOrigins in the .env
Hey Mike, thank you! Should i set, like:
corsAllowedOrigins = "*"
Or
CORSALLOWEDORIGINS = "*"
?
I've used the first but I've set it explicitly. Setting wildcards can creep into production. Look at api.go and you can see how this is implemented.
On Wed, 14 Jun 2023, 15:18 Andreh1982, @.***> wrote:
Hey Mike, thank you! Should i set, like:
corsAllowedOrigins = "*"
Or
CORSALLOWEDORIGINS = "*"
?
— Reply to this email directly, view it on GitHub https://github.com/go-skynet/LocalAI/issues/585#issuecomment-1591194739, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGK4ZK6GXXQ5AHCS3TWCAC3XLG23BANCNFSM6AAAAAAZFOPH74 . You are receiving this because you commented.Message ID: @.***>
Did you ever get this sorted?
Hello! :)
No, unfortunately nope... I tried as our friend there told me but no success. The project i'm doing haves another API who calls the LocalAI API, so i just moved the front to call new API. :)
I will close this issue, thank you so much for helping me!