我有一个 Nextjs 网站,我使用 firebase 作为后端。用户注册在本地主机上完美运行,但在部署网站时却无法正常运行。我找到了一些未得到满足的发布请求的问题。
export async function createUser({ email, password, firstName, lastName }) {
const userCredential = await createUserWithEmailAndPassword(
auth,
email,
password
);
const user = userCredential.user;
const userInfo = {
uid: user.uid,
email,
firstName,
lastName,
};
try {
await axios.post("link to api", {
id: user.uid,
data: userInfo,
});
} catch (e) {
console.log(e);
}
return userInfo;
}
const handleSubmit = async (v) => {
//input validation
try{
const account = await createUser(v);
dispatch(updateUserInfo({ ...account }));
router.push("/");
}
}
错误: { message: "请求中止", name: "AxiosError", 代码: "ECONNABORTED" }
最初该功能是直接在 NextJs 中创建文档,但这不起作用,所以我将逻辑移至后端,希望它能解决问题,但没有用
当前的问题有点简洁。 “api 链接”包含一些
hostname
。我想这在 localhost
上运行和部署时是一样的吗?
这个钉子,您确定
hostname
可以从部署您网站的服务器访问,而不仅仅是从本地主机访问吗?