Skip to content

Nuxt 3.7 nuxi dev with https does not set dev proxy header x-forwarded-proto to https #210

Description

@xelaris

After upgrading to Nuxt 3.7 URLs, generated from a backend proxied via the dev server, which is accessible via https, contain the wrong protocol ("http" instead of "https").

After some digging, it turned out that httpxy has a middleware which determines if the request came via https (hasEncryptedConnection(req) which evaluates req.connection.encrypted) and sets the x-forwarded-proto accordingly to either "http" or "https".

So far I wasn't able to find out why, but although the dev server is listening to https, the req, passed to the proxy middleware, doesn't seem to have a TLSSocket connection, hence isn't recognised to be encrypted, hence sets the wrong x-forwarded-proto header.

It worked just fine in Nuxt 3.6.

// nuxt.config.tsexportdefaultdefineNuxtConfig({nitro: {devProxy: {'/api/': {target: 'https://localhost:8000/api/',autoRewrite: true,changeOrigin: true,xfwd: true,}},devServer: {https: {key: './key.pem',cert: './cert.pem',},},});

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions