Next.js Discord

Discord Forum

invalid server action

Answered
Scaly-naped Pigeon posted this in #help-forum
Open in Discord
Avatar
Scaly-naped PigeonOP
x-forwarded-host header with value 115.85.181.105:3000 does not match origin header with value www.bbangle.store from a forwarded Server Actions request. Aborting the action.

I'm using serveraction
'use server'

import { cookies } from 'next/headers';

export const setCookie = async ({
  name,
  value,
  expires
}: {
  name: string;
  value: string;
  expires?: Date;
}) => {
  cookies().set({
    name,
    value,
    httpOnly: true,
    path: '/',
    expires
  });
};


environment: docker + ubuntu

How to fix it?
It works in Development mode
but does not works in Production
Image
Answered by Ray
/** @type {import('next').NextConfig} */
module.exports = {
  experimental: {
    serverActions: {
      allowedOrigins: ['www.bbangle.store'],
    },
  },
}

try adding the domain in next.config.js
View full answer

4 Replies

Avatar
Ray
/** @type {import('next').NextConfig} */
module.exports = {
  experimental: {
    serverActions: {
      allowedOrigins: ['www.bbangle.store'],
    },
  },
}

try adding the domain in next.config.js
Answer
Avatar
Scaly-naped PigeonOP
oh thank you i'll try it
Avatar
Scaly-naped PigeonOP
It works!
I love you 😘
thankyou
Avatar
Ray
np