Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

Mixed Content HTPPS - HTPP Error.

default discord avatar
fxhaxlast year
2

I have deployed an early version of my project on Railway; at the time of submiting a request (new user sign-up) I encounter this error:



layout-2e190bc2a1c8fba4.js:1 Mixed Content: The page at '

https://uwuteca-production.up.railway.app/sign-up

' was loaded over HTTPS, but requested an insecure resource '

http://uwuteca-production.up.railway.app/api/trpc/auth.createPayloadUser?batch=1

'. This request has been blocked; the content must be served over HTTPS.




I have tried to rederict HTPP to HTPPS in my server configuration:



imports*



const app = express();


const PORT = Number(process.env.PORT) || 3000; // Puerto local 3000 para desarrollo



const createContext = ({ req, res }: trpcExpress.CreateExpressContextOptions) => ({


req,


res,


});



export type ExpressContext = inferAsyncReturnType<typeof createContext>;



// MIDDLEWARE FOR HTPPS-HTPP


app.use((req, res, next) => {


if (req.headers['x-forwarded-proto'] !== 'https' && process.env.NODE_ENV === 'production') {


return res.redirect('https://' + req.headers.host + req.url);


}


return next();


});



const start = async () => {


// start server function


};




However, to no avail.


Anyone have an idea to solve the issue. It is much appreciated 🥲

  • default discord avatar
    notchrlast year

    Do you have a valid SSL certificate?

  • default discord avatar
    fxhaxlast year

    I believe I have, since I can access the app using https:// and http:// when entering the direction on the browser.



    I am not quite sure how a deployment service work, but I think Railway generates a SSL certificate for you automatically once you deploy.



    Solution:



    Add https:// instead of http:// at the 'NEXT_SERVER_URL' (or whatever you may called it)


    variable in the deploy settings.

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.