beego / beedoc

An open source project for beego documentation.
http://beego.me/docs
690 stars 917 forks source link

Swagger tutorial on API project is not working #487

Open aacebedo opened 8 years ago

aacebedo commented 8 years ago

Hi

I followed the tutorial found on the official website http://beego.me/docs/advantage/docs.md It does not seem to work, swagger saying CORS is not set. I have instantiated the project within a docker container so I am not using the localhost address.

The first thing is that the tutorial mentions port 8888 but by default, the port is now 8080.

Second the documentation mentions to add the line "ctx.Output.Header("Access-Control-Allow-Origin", "*")" but not in which file, I didn't found any reference to this variable anywhere in the project.

Any idea ?

aacebedo commented 8 years ago

Looks like it is missing a call to the command: bee generate docs After doing that and adding this in the main.go file

    beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
        AllowOrigins:     []string{"*"},
        AllowHeaders:     []string{"Origin"},
        ExposeHeaders:    []string{"Content-Length"},
        AllowCredentials: true,
    }))

It seems to work. Documentation shall be updated !