Fixed CORS

This commit is contained in:
2020-11-30 21:22:51 +01:00
parent ebaa93b1ea
commit b24c9dca3c
5 changed files with 22 additions and 12 deletions

21
.idea/workspace.xml generated
View File

@@ -19,10 +19,12 @@
<select />
</component>
<component name="ChangeListManager">
<list default="true" id="d639f8a9-4b6d-4957-9ba4-8361acac15ca" name="Default Changelist" comment="1.0 of Go version">
<change beforePath="$PROJECT_DIR$/.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
<list default="true" id="d639f8a9-4b6d-4957-9ba4-8361acac15ca" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Dockerfile" beforeDir="false" afterPath="$PROJECT_DIR$/Dockerfile" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app.yaml" beforeDir="false" afterPath="$PROJECT_DIR$/app.yaml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/musicFacade.go" beforeDir="false" afterPath="$PROJECT_DIR$/musicFacade.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/musicserver.go" beforeDir="false" afterPath="$PROJECT_DIR$/musicserver.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/syncFacade.go" beforeDir="false" afterPath="$PROJECT_DIR$/syncFacade.go" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -69,7 +71,7 @@
<recent name="$PROJECT_DIR$/songs" />
</key>
</component>
<component name="RunManager">
<component name="RunManager" selected="Docker.Dockerfile">
<configuration name="App Engine" type="GoApplicationRunConfiguration" factoryName="Go Application">
<module name="MusicServer" />
<working_directory value="$PROJECT_DIR$" />
@@ -170,7 +172,8 @@
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="1.0 of Go version" />
<option name="LAST_COMMIT_MESSAGE" value="1.0 of Go version" />
<MESSAGE value="Small fix in Dockerfile" />
<option name="LAST_COMMIT_MESSAGE" value="Small fix in Dockerfile" />
</component>
<component name="VgoProject">
<integration-enabled>true</integration-enabled>
@@ -192,10 +195,10 @@
<screen x="0" y="0" width="1280" height="800" />
</state>
<state x="354" y="206" key="#com.intellij.fileTypes.FileTypeChooser/0.0.1280.800@0.0.1280.800" timestamp="1606327049349" />
<state x="63" y="25" width="1120" height="702" key="CommitChangelistDialog2" timestamp="1606501993100">
<state x="63" y="25" width="1120" height="702" key="CommitChangelistDialog2" timestamp="1606502062415">
<screen x="0" y="0" width="1280" height="800" />
</state>
<state x="63" y="25" width="1120" height="702" key="CommitChangelistDialog2/0.0.1280.800@0.0.1280.800" timestamp="1606501993100" />
<state x="63" y="25" width="1120" height="702" key="CommitChangelistDialog2/0.0.1280.800@0.0.1280.800" timestamp="1606502062415" />
<state x="500" y="304" key="Github.ShareDialog" timestamp="1602604919305">
<screen x="0" y="0" width="1280" height="800" />
</state>
@@ -248,10 +251,10 @@
<screen x="0" y="0" width="1280" height="800" />
</state>
<state x="491" y="322" key="VCS.ChangelistChooser/0.0.1280.800@0.0.1280.800" timestamp="1604854207192" />
<state x="240" y="137" key="Vcs.Push.Dialog.v2" timestamp="1606501370366">
<state x="240" y="137" key="Vcs.Push.Dialog.v2" timestamp="1606502064491">
<screen x="0" y="0" width="1280" height="800" />
</state>
<state x="240" y="137" key="Vcs.Push.Dialog.v2/0.0.1280.800@0.0.1280.800" timestamp="1606501370366" />
<state x="240" y="137" key="Vcs.Push.Dialog.v2/0.0.1280.800@0.0.1280.800" timestamp="1606502064491" />
<state x="546" y="264" key="com.intellij.docker.deployment.ui.DockerPortBindingsField.v173.dialogSize" timestamp="1606060189431">
<screen x="0" y="0" width="1280" height="800" />
</state>

View File

@@ -1,5 +1,5 @@
application: musicserver
version: 2.0.0
version: 2.0.1
runtime: go115
api_version: go1

View File

@@ -163,6 +163,7 @@ func getPreviousSong() string {
}
func musicHandler(w http.ResponseWriter, r *http.Request) {
(w).Header().Set("Access-Control-Allow-Origin", "*")
if r.URL.Path == "/music" && r.Method == http.MethodGet {
song := r.URL.Query().Get("song")
if song == "" {

View File

@@ -100,14 +100,19 @@ type SongData struct {
}
func indexHandler(w http.ResponseWriter, r *http.Request) {
(w).Header().Set("Access-Control-Allow-Origin", "*")
if r.URL.Path == "/version" {
w.Header().Add("Content-Type", "application/json")
testf()
data := VersionData{Version: "2.0.0",
Changelog: "Rebuilt the application in Go.",
data := VersionData{Version: "2.0.1",
Changelog: "Fixed CORS",
History: []VersionData{
{
Version: "2.0.0",
Changelog: "Rebuilt the application in Go.",
},
{
Version: "1.2.0",
Changelog: "Made the /sync endpoint async. " +

View File

@@ -12,6 +12,7 @@ import (
)
func syncHandler(w http.ResponseWriter, r *http.Request) {
(w).Header().Set("Access-Control-Allow-Origin", "*")
if r.URL.Path == "/sync" {
w.Header().Add("Content-Type", "application/json")
syncGames()