mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-08 03:20:12 +08:00
feat: put survey and bug report url to backend (#57)
* feat: put survey and bug report url to backend * fix: centralize hardcoded url to config * fix: validate url before redirecting
This commit is contained in:
1 parent
faadcfdeaa
commit
0b8a143a63
8 files changed
+42
-5
No files matched your search
@@ -1,7 +1,6 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
|
import { surveyUrl } from '../config'
|
||||||
const SURVEY_URL = 'https://www.surveycake.com/s/z67xG'
|
|
||||||
|
|
||||||
const showModal = ref(true) // Controls whether the modal is visible or not
|
const showModal = ref(true) // Controls whether the modal is visible or not
|
||||||
|
|
||||||
@@ -27,7 +26,7 @@ setTimeout(() => {
|
|||||||
如果您能撥冗填寫這份問卷,我們將不勝感激,這對我們非常重要!
|
如果您能撥冗填寫這份問卷,我們將不勝感激,這對我們非常重要!
|
||||||
</p>
|
</p>
|
||||||
<a
|
<a
|
||||||
:href="SURVEY_URL"
|
:href="surveyUrl"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
class="inline-flex justify-center rounded-lg text-base font-black py-2 mt-3 bg-text-primary w-full"
|
class="inline-flex justify-center rounded-lg text-base font-black py-2 mt-3 bg-text-primary w-full"
|
||||||
>填寫問卷</a
|
>填寫問卷</a
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
import { onMounted, ref } from 'vue'
|
import { onMounted, ref } from 'vue'
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
import { logout } from '../utils/auth'
|
import { logout } from '../utils/auth'
|
||||||
|
import { bugReportUrl } from '../config'
|
||||||
import api from '../utils/api'
|
import api from '../utils/api'
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
@@ -11,8 +12,6 @@ const handleLogout = async () => {
|
|||||||
router.push({ name: 'login' })
|
router.push({ name: 'login' })
|
||||||
}
|
}
|
||||||
|
|
||||||
const bugReportUrl = 'https://www.surveycake.com/s/gOreA'
|
|
||||||
|
|
||||||
const questData = ref(null)
|
const questData = ref(null)
|
||||||
const questErr = ref(null)
|
const questErr = ref(null)
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
export const surveyUrl = '/api/v1/survey'
|
||||||
|
export const bugReportUrl = '/api/v1/bug-report'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
surveyUrl,
|
||||||
|
bugReportUrl,
|
||||||
|
}
|
||||||
@@ -70,6 +70,8 @@ services:
|
|||||||
- GOOGLE_CLIENT_SECRET=${GOOGLE_CLIENT_SECRET}
|
- GOOGLE_CLIENT_SECRET=${GOOGLE_CLIENT_SECRET}
|
||||||
- GITHUB_CLIENT_ID=${GITHUB_CLIENT_ID}
|
- GITHUB_CLIENT_ID=${GITHUB_CLIENT_ID}
|
||||||
- GITHUB_CLIENT_SECRET=${GITHUB_CLIENT_SECRET}
|
- GITHUB_CLIENT_SECRET=${GITHUB_CLIENT_SECRET}
|
||||||
|
- SURVEY_URL=${SURVEY_URL}
|
||||||
|
- BUG_REPORT_URL=${BUG_REPORT_URL}
|
||||||
|
|
||||||
base:
|
base:
|
||||||
image: lancatlin/linux-odyssey:base
|
image: lancatlin/linux-odyssey:base
|
||||||
|
|||||||
@@ -50,6 +50,8 @@ services:
|
|||||||
- GOOGLE_CLIENT_SECRET=${GOOGLE_CLIENT_SECRET}
|
- GOOGLE_CLIENT_SECRET=${GOOGLE_CLIENT_SECRET}
|
||||||
- GITHUB_CLIENT_ID=${GITHUB_CLIENT_ID}
|
- GITHUB_CLIENT_ID=${GITHUB_CLIENT_ID}
|
||||||
- GITHUB_CLIENT_SECRET=${GITHUB_CLIENT_SECRET}
|
- GITHUB_CLIENT_SECRET=${GITHUB_CLIENT_SECRET}
|
||||||
|
- SURVEY_URL=${SURVEY_URL}
|
||||||
|
- BUG_REPORT_URL=${BUG_REPORT_URL}
|
||||||
|
|
||||||
db-test:
|
db-test:
|
||||||
image: mongo
|
image: mongo
|
||||||
|
|||||||
@@ -38,6 +38,8 @@ services:
|
|||||||
- DOCKER_NETWORK=linux-odyssey-players
|
- DOCKER_NETWORK=linux-odyssey-players
|
||||||
- SECRET_KEY=b1d2e917-17b9-4fce-9055-082dee6ec5d6 # Only for testing
|
- SECRET_KEY=b1d2e917-17b9-4fce-9055-082dee6ec5d6 # Only for testing
|
||||||
- TRUSTED_PROXIES=${TRUSTED_PROXIES}
|
- TRUSTED_PROXIES=${TRUSTED_PROXIES}
|
||||||
|
- SURVEY_URL=${SURVEY_URL}
|
||||||
|
- BUG_REPORT_URL=${BUG_REPORT_URL}
|
||||||
- HOST_PWD=${PWD}
|
- HOST_PWD=${PWD}
|
||||||
- GOOGLE_CLIENT_ID=${GOOGLE_CLIENT_ID}
|
- GOOGLE_CLIENT_ID=${GOOGLE_CLIENT_ID}
|
||||||
- GOOGLE_CLIENT_SECRET=${GOOGLE_CLIENT_SECRET}
|
- GOOGLE_CLIENT_SECRET=${GOOGLE_CLIENT_SECRET}
|
||||||
|
|||||||
@@ -30,4 +30,20 @@ router.use(
|
|||||||
commands
|
commands
|
||||||
)
|
)
|
||||||
|
|
||||||
|
router.get('/survey', (req, res) => {
|
||||||
|
if (!config.surveyUrl) {
|
||||||
|
res.status(404).send('Survey not configured')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
res.redirect(config.surveyUrl)
|
||||||
|
})
|
||||||
|
|
||||||
|
router.get('/bug-report', (req, res) => {
|
||||||
|
if (!config.bugReportUrl) {
|
||||||
|
res.status(404).send('Bug report not configured')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
res.redirect(config.bugReportUrl)
|
||||||
|
})
|
||||||
|
|
||||||
export default router
|
export default router
|
||||||
@@ -11,6 +11,14 @@ function getTrustProxies(key) {
|
|||||||
.filter((p) => validator.isIPRange(p) || validator.isIP(p))
|
.filter((p) => validator.isIPRange(p) || validator.isIP(p))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getUrl(key) {
|
||||||
|
const url = get(key, '')
|
||||||
|
if (validator.isURL(url)) {
|
||||||
|
return validator.trim(url)
|
||||||
|
}
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
|
||||||
const config = {
|
const config = {
|
||||||
host: get('HOST', 'localhost'),
|
host: get('HOST', 'localhost'),
|
||||||
port: get('PORT', 3000),
|
port: get('PORT', 3000),
|
||||||
@@ -30,6 +38,8 @@ const config = {
|
|||||||
clientSecret: get('GITHUB_CLIENT_SECRET', ''),
|
clientSecret: get('GITHUB_CLIENT_SECRET', ''),
|
||||||
},
|
},
|
||||||
trustedProxies: getTrustProxies('TRUSTED_PROXIES'),
|
trustedProxies: getTrustProxies('TRUSTED_PROXIES'),
|
||||||
|
surveyUrl: getUrl('SURVEY_URL', ''),
|
||||||
|
bugReportUrl: getUrl('BUG_REPORT_URL', ''),
|
||||||
}
|
}
|
||||||
|
|
||||||
config.baseUrl = get('BASE_URL', `http://${config.host}:${config.port}`)
|
config.baseUrl = get('BASE_URL', `http://${config.host}:${config.port}`)
|
||||||
|
|||||||
Reference in new issue
Block a user