#Request to server Go backend server fails from my frontend app, success from anywhere else

32 messages ยท Page 1 of 1 (latest)

cedar gull
#
cors.Options{
        AllowedOrigins:   []string{"http://localhost:*"},
        AllowedMethods:   []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
        AllowedHeaders:   []string{"Accept", "Authorization", "Content-Type", "X-CSRF-Token"},
        AllowCredentials: false,
        MaxAge:           300, // Maximum value not ignored by any of major browsers
    }
#

if you're planning to use the IP directly (127.0.0.1) you need that in there too

red hornet
#

from the internet

cedar gull
#

or cors.AllowAll

nova caveBOT
cedar gull
#

chi's cors is a fork of this, so they should both work exactly the same

red hornet
#

Okay i have an issue I don't know if it comes from Go

#

Request to my go server gets refused from my svelte app

#
azureuser@myvm:~$ curl http://localhost:8080/server
{"address":"127.0.0.1","ip":"127.0.0.1","port":"8080","zone":""}
#

fails in the browser, works with curl

#

http://localhost:8080/server also works from the browser when i put in the external IP of my vm
also from postman

#

Request to server Go backend server fails from my frontend app, success from anywhere else

#

Currently have cors.AllowAll

cedar gull
#

Can you show how you apply the middleware?

wheat pagoda
#

If it's an azureVM i'm guessing you're not using the browser in a UI, so are you connecting from a remote system

#

if so localhost won't work from the frontend for obvious reasons

red hornet
#

Oh that's an interesting point, i thought maybe it was the server running in the VM connecting to the API internally but maybe the call is from the browser

#

maybe i'm just that stupid

wheat pagoda
#

you lose track sometimes when working on fullstack

#

๐Ÿ™‚

red hornet
#

Okay it can connect but now i have cors issues

#
fetcher.js?v=2c1678e5:44                  Uncaught (in promise) TypeError: Failed to fetch
    at window.fetch (fetcher.js?v=2c1678e5:44:10)
    at register (auth.ts:32:25)
    at HTMLFormElement.submit (Register.svelte? [sm]:10:26)
    at HTMLFormElement.<anonymous> (index.mjs:420:19)```
red hornet
cedar gull
#

you can still use https://* and http://* afaik?

red hornet
#

I'll try that

#

YES

#

IT WORKS