Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Header already written warning with error responses #14

Closed
gary-archer opened this issue Mar 7, 2022 · 1 comment
Closed

Header already written warning with error responses #14

gary-archer opened this issue Mar 7, 2022 · 1 comment

Comments

@gary-archer
Copy link
Collaborator

gary-archer commented Mar 7, 2022

When writing the tutorial I saw this message in logs occasionally, during tests:

header already sent while reading response header from upstream

This occurs when routing to another location within NGINX during tests.
It seems the below add_header call should use default_type instead.

location /api {
        oauth_proxy on;
        oauth_proxy_cookie_name_prefix "example";
        oauth_proxy_encryption_key $ENCRYPTION_KEY;
        oauth_proxy_trusted_web_origin "https://www.example.com";
        oauth_proxy_cors_enabled on;

        proxy_pass http://localhost/mock-api;
    }

    location /mock-api {
        add_header "content-type" "application/json";
        return 200 '{"message": "API was called successfully with an access token"';
    }
}
@gary-archer
Copy link
Collaborator Author

gary-archer commented Aug 8, 2022

The main issue was documented in this mailing list:
https://forum.nginx.org/read.php?29,280514,280521#msg-280521

rc = ngx_http_output_filter(request, &output);
ngx_http_finalize_request(request, rc);
return NGX_DONE;

Closed via these PRs:
#19
#21

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant