Facebook和Twitter分享按钮中的自定义URL(Custom URL in facebook and twitter share button)
我想在我的应用程序中单击共享按钮时共享特定链接。 Facebook分享按钮snipet
<a href="#" onclick=" window.open( 'https://www.facebook.com/sharer/sharer.php?u='+encodeURIComponent(location.href), 'facebook-share-dialog', 'width=626,height=436'); return false;"> Share on Facebook </a>
我如何输入我的自定义网址?
I want to share a particular link when clicked on a share button in my app. Facebook share button snipet
<a href="#" onclick=" window.open( 'https://www.facebook.com/sharer/sharer.php?u='+encodeURIComponent(location.href), 'facebook-share-dialog', 'width=626,height=436'); return false;"> Share on Facebook </a>
How do i input my custom url?
原文:https://stackoverflow.com/questions/18596581
最满意答案
我猜你在
public/
目录中有一个名为index.html
的文件,这是在请求/
时会得到的文件,因为这是express.static()
默认执行的操作。您可以禁用该行为,因此请求将传递给您的
/
handler:app.use(express.static(path.join(__dirname, 'public'), { index : false }));
这在此处记录 。
或者,您可以通过在静态中间件之前声明请求来确保请求命中
/
handler:app.get('/', function (req, res, next) { console.log('I'm trying to log this string'); // make sure to end the response, to prevent hanging requests. res.end(); }); app.use(express.static(path.join(__dirname, 'public')));
I'm guessing that you have a file called
index.html
in thepublic/
directory, which is the one that will get served when requesting/
, because that's whatexpress.static()
does by default.You can disable that behaviour, so the request will be passed to your
/
handler:app.use(express.static(path.join(__dirname, 'public'), { index : false }));
This is documented here.
Alternatively, you can make sure that the request hits the
/
handler by declaring it before the static middleware:app.get('/', function (req, res, next) { console.log('I'm trying to log this string'); // make sure to end the response, to prevent hanging requests. res.end(); }); app.use(express.static(path.join(__dirname, 'public')));
相关问答
更多-
IIS团队网站上有一篇博客文章,现在解释如何在IIS Express上启用远程连接 。 这是该帖子的相关部分总结: 在Vista和Win7上,从管理提示符中运行以下命令: netsh http add urlacl url=http://vaidesg:8080/ user=everyone 对于XP,首先安装Windows XP Service Pack 2支持工具。 然后从管理提示符运行以下命令: httpcfg set urlacl /u http://vaidesg1:8080/ /a D:(A;; ...
-
如何从express服务器的请求主体中解析JSON属性?(How parse JSON properties from request body in express server?)[2022-02-16]
事实证明,我在发布的对象上设置了错误的内容类型。 需要设置为: application/json; charset=UTF-8 Turns out I had incorrect content-type set in Postman on the object being posted. Needed to be set as: application/json; charset=UTF-8 -
调用upload.single('imagefile')什么都不做。 这相当于: exports.upload_image = function (req, res, next) { var upload = multer({ storage: multer.diskStorage({ destination: function (req, file, cb) { cb(null, 'public/cms/images/uplo ...
-
Json在Express应用程序中解析(Json parse in Express app)[2023-12-06]
事实证明,数据实际上是正确传输的,事实上我发送字符串让我相信这里有错误。 It turns out that the data was in fact being transferred properly, it was the fact that I was sending strings that led me to believe that there were errors here. -
因此,此请求是一个多部分文件上载,您感兴趣的文件是JSON文档。 查看快速多部分示例 。 你会想做类似的事情: 在req.files.updates.path读取connect为您保存的文件 使用JSON.parse将JSON数据解析为对象 So this request is a multipart file upload where the file you are interested in is a JSON document. Check out the express multipart exa ...
-
使用Mongoose和Express发布请求仅保存versionKey(Post request saving only versionKey with Mongoose and Express)[2022-10-15]
第一个问题,编码必须与你的Express解析相匹配(在这种情况下,它不是multipart/form-data而是application/json , 'application/vnd.api+json' ,以及application/x-www-form-urlencoded删除你指定修复的编码类型。 其次,响应将是一个简单的JSON对象: { "message": "Post saved" } First question, the encoding must match what you h ... -
因此,在深入研究这个问题(前一段时间)后,我注意到IE8和IE9上的content-type标题都是空的。 因为empty不是默认值,所以我检查了是否有什么东西干扰了我的XDomainRequest设置,我发现jQuery-ajaxTransport-XDomainRequest正在改变xdr.contentType,将其设置为“”(空)。 我为此问题创建的解决方案是Express.js中间件,用于设置/覆盖对特定路由的请求的内容类型标头。 这是一个用法示例: var express = require(' ...
-
Express:限制请求大小(Express: limit request size)[2022-09-04]
如果您希望/specialRequest的请求体的大小有限但未解析,则可以使用bodyParser.raw() 。 在这种情况下, req.body将是一个按req.body包含请求主体的Buffer实例(未解析,但如果它被表示为gzip压缩或收缩数据,它将被夸大;可以通过其选项禁用此行为)。 您需要在插入bodyParser.urlencoded()中间件之前声明它: app.post('/specialRequest', bodyParser.raw({ limit : 123, type : '*/* ... -
我猜你在public/目录中有一个名为index.html的文件,这是在请求/时会得到的文件,因为这是express.static()默认执行的操作。 您可以禁用该行为,因此请求将传递给您的/ handler: app.use(express.static(path.join(__dirname, 'public'), { index : false })); 这在此处记录 。 或者,您可以通过在静态中间件之前声明请求来确保请求命中/ handler: app.get('/', function (req ...
-
body-parser模块当前不提供multipart/form-data解析器。 为此你需要像multer , multer / connect-busboy , multiparty或者formidable 。 The body-parser module currently does not a provide a multipart/form-data parser. For that you will need something like multer, busboy/connect-busbo ...