Woooo! Login & Gallery Loading Working!
This commit is contained in:
@@ -37,7 +37,6 @@ func (api *API) mediaHandler(w http.ResponseWriter, r *http.Request) {
|
||||
rawUserID, _ := (*authContext.AccessToken).Get("sub")
|
||||
userID := rawUserID.(string)
|
||||
|
||||
// TODO: Derive Cache & Width Location
|
||||
// Derive Path
|
||||
fileName := path.Base(r.URL.Path)
|
||||
folderPath := path.Join("/" + api.Config.DataPath + "/media/" + userID)
|
||||
|
||||
@@ -52,6 +52,20 @@ func (api *API) queryMiddleware(next http.Handler) http.Handler {
|
||||
**/
|
||||
func (api *API) authMiddleware(next http.Handler) http.HandlerFunc {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
// TODO: REMOVE (SOME OF) THIS!! Only for developement due to CORS
|
||||
w.Header().Set("Access-Control-Allow-Credentials", "true")
|
||||
w.Header().Set("Access-Control-Allow-Origin", "*")
|
||||
//w.Header().Set("Access-Control-Expose-Headers", "*")
|
||||
w.Header().Set("Access-Control-Allow-Headers", "x-imagini-accesstoken,x-imagini-refreshtoken")
|
||||
w.Header().Set("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE")
|
||||
|
||||
// CORS Preflight
|
||||
if r.Method == http.MethodOptions {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
return
|
||||
}
|
||||
|
||||
// Validate Tokens
|
||||
accessToken, err := api.validateTokens(&w, r)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user