javascript - Next-absolute-url 在 Nextjs 的生产环境中不起作用
问题描述
我在 Nextjs 中使用 absoluteUrl 来获取来源。在 localhost 我得到的来源是http://localhost:3000这很好。
但是当我将此来源导入到社交共享按钮时,我得到的来源是 生产页面中的http://localhost:3000
谁能告诉我如何为生产编写代码?
const fetchRelative = (req: any) => {
const { origin } = absoluteUrl(req);
return origin;
}
const origin = await fetchRelative(reqObj);
我在我的页面中使用了此代码。
解决方案
推荐阅读
- java - 如何解决此错误:找不到符号类 DragAdapter
- python - 如何让 Pygame 渲染为我的神经网络工作?
- html - 将元素相对于另一个元素垂直居中放置
- python - 数组切片和同时赋值的时间复杂度
- css - 我正在尝试在 CSS 中悬停一个元素并在另一个元素下划线 - SquareSpace
- asp.net-mvc - 将数字发布到 SQL 时删除逗号错误:System.InvalidOperationException:
- python - 如何修复“未找到模块”和“int 对象没有属性“分割线”?
- c# - 当我以编程方式更改用户控件时,如何让数据绑定双向工作?
- flutter - 在 Flutter 中使用 PopUpMenuItem onTap/onPessed 的正确方法是什么?
- mongodb - 应该针对不同的排序和过滤条件创建哪些MongoDB索引来提高性能?