Spikatrix
04/06/2024, 1:55 PMSpikatrix
04/06/2024, 1:57 PMhttp://localhost:5173/login
and the backend is running on http://localhost:4000
Frontend code:
js
SuperTokens.init({
appInfo: {
apiDomain: 'http://localhost:4000',
apiBasePath: "/auth",
appName: "MyApp",
},
recipeList: [
Session.init(),
ThirdPartyEmailPassword.init(),
],
enableDebugLogs: !!import.meta.env.VITE_SUPERTOKENS_DEBUG,
});
and
js
emailPasswordSignIn({
formFields: [{
id: "email",
value: formData.email
}, {
id: "password",
value: formData.password
}]
})
Spikatrix
04/06/2024, 1:57 PMgo
apiBasePath := "/auth"
websiteBasePath := "/login"
err := supertokens.Init(supertokens.TypeInput{
Debug: env.SuperTokensDebug != "",
Supertokens: &supertokens.ConnectionInfo{
// https://try.supertokens.com is for demo purposes. Replace this with the address of your core instance (sign up on supertokens.com), or self host a core.
ConnectionURI: "https://my-instance.aws.supertokens.io",
APIKey: "my-api-key",
},
AppInfo: supertokens.AppInfo{
AppName: "MyApp",
APIDomain: "http://localhost:4000",
WebsiteDomain: "http://localhost:5173",
APIBasePath: &apiBasePath,
WebsiteBasePath: &websiteBasePath,
},
RecipeList: []supertokens.Recipe{
thirdpartyemailpassword.Init(&tpepmodels.TypeInput{
Providers: []tpmodels.ProviderInput{
{
Config: tpmodels.ProviderConfig{
ThirdPartyId: "google",
Clients: []tpmodels.ProviderClientConfig{
{
ClientID: env.GoogleClientID,
ClientSecret: env.GoogleClientSecret,
},
},
},
},
},
}),
dashboard.Init(),
},
})
Spikatrix
04/06/2024, 1:58 PMgo
type Server struct {
Router *chi.Mux
}
func (s *Server) MountHandlers() {
// CORS
s.Router.Use(cors.Handler(cors.Options{
AllowedOrigins: []string{"http://localhost:5173"},
AllowedMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
AllowedHeaders: append([]string{"Content-Type"},
supertokens.GetAllCORSHeaders()...),
AllowCredentials: true,
}))
// Middlewares
s.Router.Use(supertokens.Middleware)
}
Spikatrix
04/06/2024, 1:59 PMSpikatrix
04/06/2024, 2:00 PMrp_st
04/06/2024, 3:41 PMSpikatrix
04/06/2024, 4:35 PMrp_st
04/06/2024, 4:37 PMrp_st
04/06/2024, 4:37 PMSpikatrix
04/06/2024, 4:39 PMSpikatrix
04/06/2024, 4:39 PMhttp://localhost:5173/login
, then websiteBasePath := "/login"
is correct, right?Spikatrix
04/06/2024, 4:41 PMwebsiteBasePath := "/"
rp_st
04/06/2024, 4:41 PMSpikatrix
04/07/2024, 1:01 PM